Skip to content

How To: Use subdomains

smickie edited this page Jul 3, 2012 · 4 revisions

If you are using subdomains and Devise you may encounter this problem in internet explorer:

Started GET "/" for 127.0.0.1 at 2012-05-30 19:18:51 +1000
Processing by Users::DashboardController#home as HTML
Completed 401 Unauthorized in 1ms

You need to configure config/initializers/session_store.rb to share accross subdomains, for example:

MyApp::Application.config.session_store :cookie_store, key: '_my_app_session', domain: '.example.com'

To configure per environment you could use the following:

MyApp::Application.config.session_store :cookie_store, key: '_my_app_session', domain: {
  production: '.example.com',
  development: '.example.dev'
}.fetch(Rails.env.to_sym, :all)
Clone this wiki locally