子域会话无法在Heroku中使用Rails 2.3和Rails 3使用/不使用自定义域? [英] Subdomain Session Not Working in Rails 2.3 and Rails 3 on Heroku with/without a Custom Domain?
问题描述
- http://production-app.com (从 http:// production-app。 heroku.com )
- http:// development-app。 heroku.com
在 production-app.com
上,我有几个使用Heroku自定义域名插件和Zerigo(不是通配符域名插件)的子域名: b
$ b
development-app.heroku.com
上,我也有这些自定义子域名,但由于我没有自定义域名,我只是使用通配符插件。
在 routes.rb
中,使用 Subdomain-Fu ,我在本地和两个Heroku应用程序中都有子域名。
我现在面临的问题是,如何保持所有子域之间的会话同步?
我试过添加这个到 production.rb
:
ActionController :: CgiRequest :: DEFAULT_SESSION_OPTIONS。 update(:session_domain => '.production-app.com')
即使是这样的组合:
begin
config.action_controller.session [:domain] ='.production-app.com'
config.action_controller.session [:session_domain] ='.production-app.com'
rescue
config.action_controller.session = {:domain => '.production-app.com',:session_domain => .production-app.com}
end
...以及dev网站,这两个:
ActionController :: CgiRequest :: DEFAULT_SESSION_OPTIONS.update(:session_domain =>'.heroku.com ')
#或
ActionController :: CgiRequest :: DEFAULT_SESSION_OPTIONS.update(:session_domain =>'.development-app.heroku.com')
这些都不会保留子域之间的会话。当我有一个自定义域名,并且刚刚运行Heroku子域名时,我该如何获得这项工作?
谢谢!
<在您的config / initializers / session_store.rb中,告诉rails在所有域中设置cookie:
<$
p $ p> Rails.application.config.session_store:cookie_store,:key => '_yourapp_session',:domain =>:所有
与 So I have two heroku apps: On On In my The issue I'm facing now is, how do I keep the session in sync between all the subdomains? I have tried adding this to And even combinations of this: ...and for the dev site, both of these: None of those keep the session between subdomains. How do I get this working when I have a custom domain and when I'm just running off a Heroku subdomain? Thanks! In your config/initializers/session_store.rb, tell rails to set the cookie across all domains: Same as this SO question If you are wanting to persist your session between "development-app.heroku.com" and "production-app.com" that cannot be done unless those are the same codebase. If they are the same codebase, then use a before_filter on your application controller to redirect to production-app.com 这篇关于子域会话无法在Heroku中使用Rails 2.3和Rails 3使用/不使用自定义域?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
production-app.com
, I have several subdomains using the Heroku custom domains addon with Zerigo (not the wildcard domain addon):development-app.heroku.com
, I also have those custom subdomains, but since I don't have a custom domain, I just use the wildcard addon.routes.rb
, using Subdomain-Fu, I have the subdomains working locally and on both Heroku apps.production.rb
:ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.production-app.com')
begin
config.action_controller.session[:domain] = '.production-app.com'
config.action_controller.session[:session_domain] = '.production-app.com'
rescue
config.action_controller.session = {:domain => '.production-app.com', :session_domain => ".production-app.com"}
end
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.heroku.com')
# or
ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.development-app.heroku.com')
Rails.application.config.session_store :cookie_store, :key => '_yourapp_session', :domain=>:all