在设计 SSL 控制器后返回 HTTP
我试图在 Devise
操作之后将请求重定向到 HTTP。我不确定我想做的是否是正确/最好的方法,所以我愿意接受建议。这是我所拥有的,它因“重定向循环”而失败,这是可以理解的。现在我只需要弄清楚如何在重定向后终止请求。
这是否值得追求,或者有更好的方法吗?
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :https_only_for_devise
@@ssl_controllers = ['devise/registrations',
'devise/sessions']
def https_only_for_devise
if (@@ssl_controllers.index(params[:controller]) == nil)
redirect_to :protocol => 'http://'
end
end
end
I am trying to redirect requests to HTTP after Devise
actions. I'm not sure if what I'm trying to do is the right/best way so I'm open to suggestion. Here's what I have and it's failing with a "redirect loop", which is understandable. Now I just need to figure out how to terminate the request after the redirect.
Is this worth pursuing, or is there a better way?
class ApplicationController < ActionController::Base
protect_from_forgery
before_filter :https_only_for_devise
@@ssl_controllers = ['devise/registrations',
'devise/sessions']
def https_only_for_devise
if (@@ssl_controllers.index(params[:controller]) == nil)
redirect_to :protocol => 'http://'
end
end
end
它成功了!将方法的内容更改为:
现在我已经考虑过了,这非常明显......
And it worked! Changed the content of the method to:
Incredibly obvious now that I've thought about it...