繁体   English   中英

Rails 4-登录后重定向到页面的锚点部分

[英]Rails 4 - Redirect to anchor section of a page after login

Rails 4.2.4-当我单击电子邮件中的链接时,它将要求登录。 登录后,它将重定向到适当的页面,但是在该页面中,有很多部分。 如何重定向到特定部分?

在控制器中:

def after_sign_in_path_for(resource)
  session[:return_to] || root_url
end

user_new_path(:anchor=>'profile_pic')是链接。

在视图中:

<div id='other_details'>
  ...
</div>
<div id='profile_pic'>
  ...
</div>

如何解决此重定向问题?

尝试使用

user_new_path + '#profile_pic'

在after_sign_in_path_for方法中。

希望有帮助!

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM