Skip to content

Commit

Permalink
issue with using ':domain => :all' in session_store is resolved with …
Browse files Browse the repository at this point in the history
…a recent commit to Rails master
  • Loading branch information
fortuity committed Aug 17, 2010
1 parent ab5b7df commit 7bfd0a4
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 23 deletions.
3 changes: 3 additions & 0 deletions Gemfile
@@ -1,5 +1,8 @@
source 'http://rubygems.org'

# Uncomment the following to use the GitHub master (unreleased) version of Rails 3
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# Or use the Rails 3 release candidate
gem 'rails', '3.0.0.rc'
gem 'sqlite3-ruby', :require => 'sqlite3'
gem 'devise', '1.1.1'
Expand Down
39 changes: 22 additions & 17 deletions Gemfile.lock
@@ -1,7 +1,7 @@
GEM
remote: http://rubygems.org/
GIT
remote: git://github.com/rails/rails.git
revision: dd55830
specs:
abstract (1.0.0)
actionmailer (3.0.0.rc)
actionpack (= 3.0.0.rc)
mail (~> 2.2.5)
Expand All @@ -28,6 +28,24 @@ GEM
activemodel (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
activesupport (3.0.0.rc)
rails (3.0.0.rc)
actionmailer (= 3.0.0.rc)
actionpack (= 3.0.0.rc)
activerecord (= 3.0.0.rc)
activeresource (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
bundler (>= 1.0.0.rc.2)
railties (= 3.0.0.rc)
railties (3.0.0.rc)
actionpack (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
rake (>= 0.8.3)
thor (~> 0.14.0)

GEM
remote: http://rubygems.org/
specs:
abstract (1.0.0)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
babosa (0.1.0)
Expand All @@ -52,19 +70,6 @@ GEM
rack (>= 1.0.0)
rack-test (0.5.4)
rack (>= 1.0)
rails (3.0.0.rc)
actionmailer (= 3.0.0.rc)
actionpack (= 3.0.0.rc)
activerecord (= 3.0.0.rc)
activeresource (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
bundler (>= 1.0.0.rc.1)
railties (= 3.0.0.rc)
railties (3.0.0.rc)
actionpack (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
rake (>= 0.8.3)
thor (~> 0.14.0)
rake (0.8.7)
sqlite3-ruby (1.3.1)
thor (0.14.0)
Expand All @@ -80,5 +85,5 @@ PLATFORMS
DEPENDENCIES
devise (= 1.1.1)
friendly_id (= 3.1.1.1)
rails (= 3.0.0.rc)
rails!
sqlite3-ruby
11 changes: 10 additions & 1 deletion README.textile
Expand Up @@ -181,7 +181,16 @@ You can use the Site model, controller, and views as a beginning point for custo

h2. Issues

See the "Tutorial":http://wiki.github.com/fortuity/rails3-subdomain-devise/tutorial-walkthrough for a detailed description of an issue with the Rails 3 release candidate, cookies, and subdomains. Specifically, the Rails 3 release candidate does not behave as expected when @:domain => :all@ is set in *config/initializers/session_store.rb*. Using the parameter @:domain => :all@ allows us to avoid hardcoding the domain name in the app, making it possible to test the app on our localhost machine and deploy it without changes. Until the issue is resolved with Rails 3, use @:domain => ".lvh.me"@ for development and then change it when you deploy it elsewhere.
See the "Tutorial":http://wiki.github.com/fortuity/rails3-subdomain-devise/tutorial-walkthrough for a detailed description of an issue with the Rails 3 release candidate, cookies, and subdomains. Specifically, the Rails 3 release candidate does not behave as expected when @:domain => :all@ is set in *config/initializers/session_store.rb*. Using the parameter @:domain => :all@ allows us to avoid hardcoding the domain name in the app, making it possible to test the app on our localhost machine and deploy it without changes. As a workaround, use @:domain => ".lvh.me"@ for development and then change it when you deploy it elsewhere.

This issue is resolved with the Rails 3 master on GitHub. See "commit fd78bb72704554737117":http://github.com/rails/rails/commit/fd78bb727045547371179428886c9b262d66091d by Bryce Thornton. You can install the Rails 3 master from GitHub by changing your Gemfile and running @bundle install@.

<pre>
gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'rails', '3.0.0.rc'
</pre>

After you run @bundle install@ you can should see the latest commit number from the master Rails repo in the *Gemfile.lock* file.

h2. Testing

Expand Down
13 changes: 10 additions & 3 deletions TUTORIAL.textile
Expand Up @@ -1085,11 +1085,18 @@ Compare this with setting @:domain => ".lvh.me"@. Clear all cookies and restart

In conclusion, the Rails 3 release candidate works as expected with the setting @:domain => ".lvh.me"@ but not @:domain => :all@.

*Note:* Is this related to "an open bug":https://rails.lighthouseapp.com/projects/8994/tickets/5147-the-all-domain-option-for-the-cookie-session-store-doesnt-allow-non-standard-tlds-like-local-or-couk in the Rails 3 release candidate?
*Workaround:* As a workaround, use @:domain => ".lvh.me"@ for development and then change it when you deploy it elsewhere.

h4. Workaround
h4. Issue Resolved in Rails 3 Master

Until the issue is resolved with Rails 3, use @:domain => ".lvh.me"@ for development and then change it when you deploy it elsewhere.
This issue is resolved with the Rails 3 master on GitHub. See "commit fd78bb72704554737117":http://github.com/rails/rails/commit/fd78bb727045547371179428886c9b262d66091d by Bryce Thornton. You can install the Rails 3 master from GitHub by changing your Gemfile and running @bundle install@.

<pre>
gem 'rails', :git => 'git://github.com/rails/rails.git'
#gem 'rails', '3.0.0.rc'
</pre>

After you run @bundle install@ you can should see the latest commit number from the master Rails repo in the *Gemfile.lock* file.

h2. Conclusion

Expand Down
2 changes: 1 addition & 1 deletion config/initializers/session_store.rb
@@ -1,6 +1,6 @@
# Be sure to restart your server when you modify this file.

Rails3SubdomainDevise::Application.config.session_store :cookie_store, :key => '_rails3-subdomain-devise_session'
Rails3SubdomainDevise::Application.config.session_store :cookie_store, :domain => :all, :key => '_rails3-subdomain-devise_session'

# Use the database for sessions instead of the cookie-based default,
# which shouldn't be used to store highly confidential information
Expand Down
2 changes: 1 addition & 1 deletion template.rb
Expand Up @@ -750,7 +750,7 @@ def limit_subdomain_access
run 'rake db:seed'

puts "allow cookies to be shared across subdomains"
inject_into_file 'config/initializers/session_store.rb', ":domain => '.lvh.me', ", :after => ":cookie_store, "
inject_into_file 'config/initializers/session_store.rb', ":domain => :all, ", :after => ":cookie_store, "

puts "checking everything into git..."
git :add => '.'
Expand Down

0 comments on commit 7bfd0a4

Please sign in to comment.