gpt4 book ai didi

ruby-on-rails - 为我的支付 Controller 实现 http

转载 作者:太空宇宙 更新时间:2023-11-03 13:27:24 25 4
gpt4 key购买 nike

我使用的是 Rails 3.2,我希望我的付款表单能够重定向到 https。

我在 routes.rb 中尝试了以下方法,但没有用:

resources :payments, only: [:new, :create], :constraints => { :protocol => "https" }

我收到的错误是:

No route matches [GET] "/payments/new"

目前我正在我的本地环境中测试它,它在没有contraints

的情况下工作正常

最佳答案

您想重定向到 payments/new 路由的 https 版本,而不是对其施加约束。这就是您看到 No route 错误的原因(假设您没有在本地主机上使用 https)。在 here 上阅读有关做您想做的事的信息.这是一个简洁的 Rack 中间件 gem,您可以使用它来进行重定向:https://github.com/josh/rack-ssl

关于ruby-on-rails - 为我的支付 Controller 实现 http,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22995168/

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