diff options
author | Prem Sichanugrist <s@sikachu.com> | 2012-08-24 17:02:27 -0400 |
---|---|---|
committer | Prem Sichanugrist <s@sikachu.com> | 2012-08-24 17:05:14 -0400 |
commit | 1807384c96c553af780e98d25ab4750389233f77 (patch) | |
tree | 2dedca55093b5d975903c09ff8738f1a0bd1be46 /railties | |
parent | 19a3eda011bbfae7b7416cfd9b1d5aff6fbffc97 (diff) | |
download | rails-1807384c96c553af780e98d25ab4750389233f77.tar.gz rails-1807384c96c553af780e98d25ab4750389233f77.tar.bz2 rails-1807384c96c553af780e98d25ab4750389233f77.zip |
Raise more helpful error message on missing gem
Tell people to install `activerecord-session_store` gem when it's not
installed instead ofraising `NameError` on missing
`ActionDispatch::Session::ActiveRecordStore`.
Diffstat (limited to 'railties')
-rw-r--r-- | railties/lib/rails/application/configuration.rb | 7 | ||||
-rw-r--r-- | railties/test/application/configuration_test.rb | 19 |
2 files changed, 26 insertions, 0 deletions
diff --git a/railties/lib/rails/application/configuration.rb b/railties/lib/rails/application/configuration.rb index f8ddeeb99e..0202e86f32 100644 --- a/railties/lib/rails/application/configuration.rb +++ b/railties/lib/rails/application/configuration.rb @@ -125,6 +125,13 @@ module Rails case @session_store when :disabled nil + when :active_record_store + begin + ActionDispatch::Session::ActiveRecordStore + rescue NameError + raise "`ActiveRecord::SessionStore` is extracted out of Rails into a gem. " \ + "Please add `activerecord-session_store` to your Gemfile to use it." + end when Symbol ActionDispatch::Session.const_get(@session_store.to_s.camelize) else diff --git a/railties/test/application/configuration_test.rb b/railties/test/application/configuration_test.rb index ebdbbaee8b..039b08c723 100644 --- a/railties/test/application/configuration_test.rb +++ b/railties/test/application/configuration_test.rb @@ -630,5 +630,24 @@ module ApplicationTests ActiveRecord::Base assert defined?(FooObserver) end + + test "config.session_store with :active_record_store with activerecord-session_store gem" do + begin + make_basic_app do |app| + ActionDispatch::Session::ActiveRecordStore = Class.new(ActionDispatch::Session::CookieStore) + app.config.session_store :active_record_store + end + ensure + ActionDispatch::Session.send :remove_const, :ActiveRecordStore + end + end + + test "config.session_store with :active_record_store without activerecord-session_store gem" do + assert_raise RuntimeError, /activerecord-session_store/ do + make_basic_app do |app| + app.config.session_store :active_record_store + end + end + end end end |