我的rails应用程序中有两个独立的登录模型:
我的佣金路线输出是: 耙路线| grep devise
new_admin_session GET /admins/sign_in(.:format) devise/sessions#new
admin_session POST /admins/sign_in(.:format) devise/sessions#create
destroy_admin_session DELETE /admins/sign_out(.:format) devise/sessions#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session DELETE /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
在ApplicationController中我有
def after_sign_in_path_for(resource)
request.referrer
end
它适用于我的用户模型,但如何为我的管理模型执行此操作,以便在登录后我重定向到同一页面(我使用内置设计控制器),如after_admin_sign_in_path_for(resource)
因为如果我这样写,我有记录:
Filter chain halted as :require_no_authentication rendered or redirected
答案 0 :(得分:14)
def after_sign_in_path_for(resource)
case resource
when User then request.referrer
when Admin then ....
end
end