[英]Devise: Overriding the sessions#new action
I want to be able to send already-signed-in-users somewhere else when they go to the sign in page . 我希望能够在登录页面时将已签名的用户发送到其他地方 。 Right now they are sent to the root path.
现在他们被发送到根路径。
I tried making my own new action in sessions controller but it doesn't seem to work. 我尝试在会话控制器中创建自己的新动作但它似乎不起作用。 The text I try to print out on the log to test out doesn't even come out, so I think the user is redirected somewhere up the chain.
我尝试在日志上打印出来测试的文本甚至没有出来,所以我认为用户被重定向到链的某个地方。
How do you do this? 你怎么做到这一点?
I think what you are looking for is after_sign_in_path_for . 我认为你要找的是after_sign_in_path_for 。 If you define that method in your application_controller.rb file you can return whatever path you want the user to be redirected to.
如果在application_controller.rb文件中定义该方法,则可以返回希望用户重定向到的任何路径。
def after_sign_in_path_for(resource)
if current_user.current_sign_in_at > 1.minute.ago
your_own_path
else
super
end
end
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.