配置 session_store.rb 来处理登台和生产?
我的 Rails 3.1rc6 应用程序上有一个使用子域的暂存和生产环境。我为这些环境购买并配置了不同的域名,因为默认的 some-something.herokuapp.com 不能很好地与子域配合。
当我将 session_store.rb 设置为一个环境时,一切正常:
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk'
但我似乎无法添加条件以允许特定于环境的域名。
我已经尝试过
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk' if Rails.env.staging?
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.myproductiondomain.com' if Rails.env.production?
哪个不起作用。
I have a staging and a production environment on my rails 3.1rc6 app which uses subdomains. I've bought and configured different domain names for these environments, because the default something-something.herokuapp.com doesn't play nicely with subdomains.
When I set session_store.rb to this for one environment, everything works fine:
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk'
But I can't seem to add in a conditional to allow for the environment-specific domain names.
I've tried
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.mystagingdomain.co.uk' if Rails.env.staging?
AppName::Application.config.session_store :cookie_store, :key => '_sample_app_session' , :domain => '.myproductiondomain.com' if Rails.env.production?
which doesn't work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
以下设置对我来说工作正常:
config/environments/staging.rb
config/environments/development.rb
The following settings has been working fine for me:
config/environments/staging.rb
config/environments/production.rb
您可以使用
:domain =>; :all
选项。您还可以提供:tld_length
(如果不同于 1)。这是相关的 Rails 代码。
否则,您还应该能够覆盖
config/environments/ENVIRONMENT.rb
中的设置code> 每个环境的文件。You can use the
:domain => :all
option. You can also provide a:tld_length
, if different than 1.Here's the relevant Rails code
Otherwise, you should also be able to override the settings in the
config/environments/ENVIRONMENT.rb
file on a per-environment basis.