通过对user_auth使用设计,它设置了一些默认路由(例如/ user / edit和/ user / sign_in)。在routes.rb我有
devise_scope :user do
get 'signin' => 'devise/sessions#new'
etc.
end
问题是/ signin和/ user / sign_in都可以链接到登录页面。我想如何使/ user / sign_in链接处于非活动状态,这意味着在导航到该页面时会出现404错误。
我的佣金路线是:
new_user_session GET /users/sign_in(.:format) {:action=>"new", :controller=>"devise/sessions"}
user_session POST /users/sign_in(.:format) {:action=>"create", :controller=>"devise/sessions"}
destroy_user_session DELETE /users/sign_out(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
user_password POST /users/password(.:format) {:action=>"create", :controller=>"devise/passwords"}
new_user_password GET /users/password/new(.:format) {:action=>"new", :controller=>"devise/passwords"}
edit_user_password GET /users/password/edit(.:format) {:action=>"edit", :controller=>"devise/passwords"}
PUT /users/password(.:format) {:action=>"update", :controller=>"devise/passwords"}
cancel_user_registration GET /users/cancel(.:format) {:action=>"cancel", :controller=>"registrations"}
user_registration POST /users(.:format) {:action=>"create", :controller=>"registrations"}
new_user_registration GET /users/sign_up(.:format) {:action=>"new", :controller=>"registrations"}
edit_user_registration GET /users/edit(.:format) {:action=>"edit", :controller=>"registrations"}
PUT /users(.:format) {:action=>"update", :controller=>"registrations"}
DELETE /users(.:format) {:action=>"destroy", :controller=>"registrations"}
signin GET /signin(.:format) {:action=>"new", :controller=>"devise/sessions"}
signout GET /signout(.:format) {:action=>"destroy", :controller=>"devise/sessions"}
signup GET /signup(.:format) {:action=>"new", :controller=>"devise/registrations"}
command GET /command(.:format) {:action=>"edit", :controller=>"devise/registrations"}
答案 0 :(得分:1)
使用devise_for更改默认网址的路径和名称
devise_for :users, :path => '', :path_names => { :sign_in => 'signin', :sign_out => 'signout', :sign_up => 'signup' }
我建议将路径名称保留为sign_in,sign_out和sign_up,因为signin看起来像乱码。
此外,选择性地编辑这些默认值可能只会让您的路线从长远来看更加混乱。因此,除非有很好的理由来覆盖默认值,否则你应该选择设计建议。