gpt4 book ai didi

ruby-on-rails - 在设计 SSL Controller 之后返回到 HTTP

转载 作者:太空宇宙 更新时间:2023-11-03 14:20:21 30 4
gpt4 key购买 nike

我正在尝试在 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

最佳答案

成功了!将方法的内容更改为:

  def https_only_for_devise
if (@@ssl_controllers.index(params[:controller]) == nil && request.ssl?)
redirect_to :protocol => 'http://'
end
end

现在我已经考虑过了,非常明显......

关于ruby-on-rails - 在设计 SSL Controller 之后返回到 HTTP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7841533/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com