Ruby on rails 在SSL重定向后,POST请求更改为GET请求
我想在Rails应用程序中以用户身份登录。没有SSL,一切正常。当在登台/生产上激活SSL时,会有一个SSL重定向,用于在GET请求中更改我的POST请求。因此,将调用会话控制器中的SHOW方法,而不是调用CREATE方法。以下是日志:Ruby on rails 在SSL重定向后,POST请求更改为GET请求,ruby-on-rails,ssl,nginx,Ruby On Rails,Ssl,Nginx,我想在Rails应用程序中以用户身份登录。没有SSL,一切正常。当在登台/生产上激活SSL时,会有一个SSL重定向,用于在GET请求中更改我的POST请求。因此,将调用会话控制器中的SHOW方法,而不是调用CREATE方法。以下是日志: Started POST "/authentication_customer_user_sessions" for *********** at 2014-07-30 10:42:30 +0200 Processing by Authentication::
Started POST "/authentication_customer_user_sessions" for *********** at 2014-07-30 10:42:30 +0200
Processing by Authentication::CustomerUserSessionsController#create as HTML
Parameters: {"utf8"=>"✓", "authentication_customer_user_session"=>{"redirect_path"=>"user_index_path", "login"=>"user", "password"=>"[FILTERED]", "remember_me"=>"0"}, "account"=>{"signup"=>"with_signup"}, "commit"=>"signin"}
Redirected to https://staging.myserver.de/authentication_customer_user_sessions
Completed 302 Found in 5ms
Started GET "/authentication_customer_user_sessions" for *********** at 2014-07-30 10:42:30 +0200
AbstractController::ActionNotFound (The action 'show' could not be found for Authentication::CustomerUserSessionsController):
在我的Authentication::CustomerUserSession控制器中,我使用
private
def ssl_required?
return false if request.local? || RAILS_ENV == 'test' || RAILS_ENV == 'development'
true
end
那么,我可以在Rails应用程序中做些什么来避免此问题,而不停用此控制器的SSL?谢谢你的帮助
我正在使用authlogic进行身份验证。好的,我解决了我的问题。解决方案是在登录表单中强制使用
https
。这是我的代码片段:
<%= form_for Authentication::CustomerUserSession.new, :as => :authentication_customer_user_session, :url => authentication_customer_user_sessions_url(:protocol => 'https') do |f| %>
:authentication_customer_user_session,:url=>authentication_customer_user_sessions_url(:protocol=>'https')do | f |%>
或者更一般一点:
<%= form_for Authentication::CustomerUserSession.new, :as => :authentication_customer_user_session, :url => authentication_customer_user_sessions_url(:protocol => (Rails.env.production? || Rails.env.staging?) ? 'https' : 'http') do |f| %>
:authentication_customer_user_session,:url=>authentication_customer_user_sessions_url(:protocol=>(Rails.env.production?| | | Rails.env.staging?)'https':'http')do | f |%>
也许我必须在登录表单中强制SSL,这样就不会安排重定向(?)这就是重定向的工作方式。只需首先请求httpshttps
,这样就不会发生重定向,您的答案将被发送到anks@AlexeyTen。我试图在我的表单中强制使用https
,但我在语义表单中的语法方面遇到了困难:/你知道这在语义表单中是如何工作的吗?目前看起来是这样的::身份验证\客户\用户\会话,:url=>身份验证\客户\用户\会话\路径do | f |%>