开发者

Rails 3 - Help! Subdomains - Users Cannot Logout?

I've followed the ascii cast up at http://asciicasts.com/episodes/221-subdomains-in-rails-3

I've set the :domain option to :all in session stor开发者_高级运维e:

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

Now my users cannot logout.

Any ideas why? I've tried deleting all cookies and then trying again, etc.

I can login, and my session is carried across subdomains, but I can't logout.

I am using rails 3, and authlogic for authentication.

Thanks for any help!


Specify the Domain.

I had the exact same issue and the culprit was using :domain => :all.

You'd think that would be all you need but it seems to cause some problems so I had to manually specify the domain with a preceding dot (.), like so:

:domain => '.lvh.me'

This fixed the issue in development. You can use different ways to set this in your various environments but I landed on something like this:

Rails.application.config.session_store :cookie_store, 
  :key => '_bloggit_session',
  :domain => { production:  '.bloggit.com',
               staging:     '.bloggitstaging.com',
               development: '.lvh.me' }.fetch(Rails.env.to_sym)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜