[英]Rails 4 - Redirect to anchor section of a page after login
Rails 4.2.4 - When I clicked on a link from an email it will ask for login. Rails 4.2.4-当我单击电子邮件中的链接时,它将要求登录。 After logged in, it will redirect to a proper page but in that page, many sections are there. 登录后,它将重定向到适当的页面,但是在该页面中,有很多部分。 How can I redirect to particular section? 如何重定向到特定部分?
In controller: 在控制器中:
def after_sign_in_path_for(resource)
session[:return_to] || root_url
end
user_new_path(:anchor=>'profile_pic')
is the link. user_new_path(:anchor=>'profile_pic')
是链接。
In views: 在视图中:
<div id='other_details'>
...
</div>
<div id='profile_pic'>
...
</div>
How can I solve this redirect issue? 如何解决此重定向问题?
Try using 尝试使用
user_new_path + '#profile_pic'
in after_sign_in_path_for method. 在after_sign_in_path_for方法中。
Hope that helps! 希望有帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.