2012-01-16 50 views
0

设计出具有重定向功能,允许用户返回到他在登录前的页面后,POST请求Ruby on Rails的设计 - 重定向认证

问题是,它仅与GET的工作。如果用户在POST期间被停止进行身份验证(例如填写表单),他将被相应地重定向,但是使用GET。

有什么办法正确完成改变这种做法,这个职位吗?

非常感谢。

+1

您无法通过POST重定向http://stackoverflow.com/questions/985596/redirect-to-using-post-in-rails – clyfe 2012-01-16 18:12:51

+0

您可以尝试在显示表单前对用户进行身份验证,以免两次输入表单字段。 – 2012-01-16 18:30:02

回答

0

请确保您的C:\ Ruby192 \ lib \ ruby​​ \ gems \ 1.9.1 \ gems \ devise-1.1.5 \ app \ views \ devise \ shared(路径可能有所不同)中的_links.erb文件与以下内容。

<%- if controller_name != 'sessions' %> 
    <%= link_to "Sign in", new_session_path(resource_name) %><br /> 
<% end -%> 
<%- if devise_mapping.recoverable? && controller_name != 'passwords' %> 
    <%= link_to "Forgot your password?", new_password_path(resource_name) %><br /> 
<% end -%> 
<%- if devise_mapping.confirmable? && controller_name != 'confirmations' %> 
    <%= link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name) %><br /> 
<% end -%> 
<%- if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %> 
    <%= link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name) %> <br /> 
<% end -%> 

希望你能得到解决方案。