Subdomain not working in Rails 2.3 and Rails 3 on Heroku with / without user domain?

So, I have two heroku applications:

In production-app.com , I have several subdomains that use Heroku domain name addons with Zerigo (and not a wildcard addon):

At development-app.heroku.com I also have these custom subdomains, but since I don't have a custom domain, I just use a wildcard .

In my routes.rb , using Subdomain-Fu , I have subdomains working locally and on both Heroku applications.

The problem I am facing right now is how to maintain session synchronization between all sub-areas?

I tried adding this to production.rb :

 ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.production-app.com') 

And even combinations of this:

 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 

... and for the dev site, both of them:

 ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.heroku.com') # or ActionController::CgiRequest::DEFAULT_SESSION_OPTIONS.update(:session_domain => '.development-app.heroku.com') 

None of them support a session between subdomains. How can I make this work when I have my own domain and when I just run away from the Heroku subdomain?

Thanks!

+4
source share
2 answers

In your config / initializers / session_store.rb, tell rails to set a cookie for all domains:

 Rails.application.config.session_store :cookie_store, :key => '_yourapp_session', :domain=>:all 

Same as this SO question

If you want to keep your session between "development-app.heroku.com" and "production-app.com", which cannot be executed if they are not the same code base. If they are the same code base, then use before_filter on your application controller to redirect to production-app.com

+7
source

On development-app.heroku.com I also have these custom subdomains, but since I don't have a custom domain, I just use a wildcard .

Is this addon available for use with custom subdomains like api.mydevdomain.herokuapp.com ?

0
source

Source: https://habr.com/ru/post/1344120/


All Articles