我需要一些帮助。
我试图从Devise可注册模块中消除销毁和取消的路由路径,但没有成功。
Route.rb
devise_for :users, :skip => [:registrations], controllers: {
sessions: 'users/sessions',
confirmations: 'users/confirmations',
passwords: 'users/passwords'
}
get '/users/sign_up', to: 'users/registrations#new'
get '/users/edit', to: 'users/registrations#edit'
post '/users', to: 'users/registrations#create'
put '/users', to: 'users/registrations#update'
Model.rb
devise :database_authenticatable, :registerable,
:recoverable, :trackable, :validatable, :confirmable
铁路路线
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
user_registration PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
POST /users(.:format) devise/registrations#create
您可以在Rails路线中看到,即使为devise/registrations
方法设置了选项:skip
,Devise仍在创建路线路径devise_for
。有人已经面临这个问题吗?
谢谢。
答案 0 :(得分:0)
与skip一起还添加skip_helpers:true。
skip_helpers:跳过生成new_session_path(@user)
之类的Devise url帮助器。
这对于避免与以前的路由冲突很有用,默认情况下为false。
它接受true作为选项,这意味着它将跳过控制器的所有帮助程序
:skip中给出,但它也接受要跳过的特定帮助器:
devise_for :users, skip: [:registrations, :confirmations], skip_helpers: true
devise_for :users, skip_helpers: [:registrations, :confirmations]
来源: 来自设计文档 https://github.com/plataformatec/devise/blob/master/lib/devise/rails/routes.rb#L160