为Rails 2中的所有页面设置ssl_allowed / ssl_required? [英] Set ssl_allowed/ssl_required for all pages in Rails 2?
问题描述
当页面使用SSL / HTTPS时,我发现AJAX调用无法在我的Rails站点上运行。我通过添加
I found that AJAX calls were not working on my Rails site when a page was using SSL/HTTPS. I worked around this by adding
ssl_allowed :action1, :action2, :actionN
给所涉及的控制器。
我预见这是一个痛苦,容易出现问题未来,因为我无疑会忘记在ssl_allowed列表中添加一个动作。
I foresee this being a pain and prone to bugs in the future, as I'll indubitably forget to add an action to the ssl_allowed list.
有没有办法打开 ssl_allowed $ c对于我网站中每个控制器的所有操作,[ssl_requirement] [1] gem中全局$ c> /
ssl_required
?我尝试将以下内容添加到ApplicationController,但这不起作用:
Is there a way to turn on ssl_allowed
/ssl_required
globally in the [ssl_requirement][1] gem, for all actions of every controller in my site? I tried adding the following to ApplicationController, but that did not work:
ssl_allowed :all
推荐答案
我在github找到了grosser的ssl_requirement fork( link )启用ssl_allowed:all并用该版本替换我的gem副本。现在我在我的ApplicationController中使用ssl_allowed:all,而不是其他地方。正是我想要的。
I found grosser's ssl_requirement fork at github (link) which enables "ssl_allowed :all" and replaced my copy of the gem with that version. Now I'm using "ssl_allowed :all" in my ApplicationController and nowhere else. Exactly what I wanted.
这篇关于为Rails 2中的所有页面设置ssl_allowed / ssl_required?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!