跳过/禁用 rails 中特定控制器的 force_ssl [英] skip/disable force_ssl for particular controller in rails

查看:36
本文介绍了跳过/禁用 rails 中特定控制器的 force_ssl的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在应用程序中的所有路由上强制使用 SSL,message#new 控制器除外.

I need to force SSL on all routes in my application except for message#new controller.

config/environments/production.rb 中,我有:

config.force_ssl = true

现在所有路由都被重定向到 https,现在我想为 message#new 控制器禁用它.

Now all routes being redirect to https, And now I want to disable that for message#new controller.

有谁知道如何为 Rails 4+ 应用程序中的特定控制器禁用强制 SSL?

Does anyone know how to disable force SSL for particular controller in a Rails 4+ application?

推荐答案

skip_before_action :verify_authenticity_token
force_ssl except: [:index,:create]

它对我有用.

这篇关于跳过/禁用 rails 中特定控制器的 force_ssl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆