如果我输入了无效的用户名或密码
/admin/sign_in
。
设计重定向到/administrators/sign_in
而不是/admin/sign_in
。
这是我的routes.rb
devise_for :administrators
devise_scope :administrator do
get "/admin/sign_in" => "devise/sessions#new"
end
rake routes | grep sing_in
:
new_administrator_session GET /administrators/sign_in devise/sessions#new
administrator_session POST /administrators/sign_in devise/sessions#create
admin_sign_in GET /admin/sign_in devise/sessions#new
我正在跑步:
ruby'2.1.2'
rails'4.2.0'
设计'〜> 3.4.1'
答案 0 :(得分:1)
get
只会增加您现有的路线。您需要停止Devise创建默认会话路由,然后创建自己的路由。尝试添加更改路线到:
devise_for :administrators, :skip => [:sessions]
as :user do
get 'admin/sign_in' => 'devise/sessions#new', :as => :new_user_session
post 'admin/sign_in' => 'devise/sessions#create', :as => :user_session
delete 'admin/sign_out' => 'devise/sessions#destroy', :as => :destroy_user_session
end
文档here中的更多信息。
答案 1 :(得分:0)
将您的路线更改为
devise_for :administrators, :skip => [:sessions]
devise_scope :administrator do
get "/admin/sign_in" => "devise/sessions#new"
end