如何在单击登录之前定义设计 after_sign_in_path 以重定向到页面用户?我已经在 application_controller 中尝试过这个:
13 def after_sign_in_path_for(resource_or_scope)
14 sign_in_url = url_for(:action => 'new', :controller => 'my_sessions', :only_path => false, :protocol => 'http')
15 if request.referer == sign_in_url
16 super
17 else
18 stored_location_for(resource_or_scope) || request.referer || root_path
19 end
20 end
有了这个,我只会被重定向到 root_path。值得一提的是,我有用于 Sessions 的自定义控制器,称为 MySessionsController。我究竟做错了什么?