aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-02-05 20:20:39 -0600
committerJoshua Peek <josh@joshpeek.com>2009-02-05 20:22:43 -0600
commit7259baab4722d2343cbd0d81cb2aacc95d0c9461 (patch)
tree552fcc3f899c6ba6d3b57b926dd5d3ba7c559b7b /actionpack
parent96d610553e5fdaabc923835ab1f194070ddb4477 (diff)
downloadrails-7259baab4722d2343cbd0d81cb2aacc95d0c9461.tar.gz
rails-7259baab4722d2343cbd0d81cb2aacc95d0c9461.tar.bz2
rails-7259baab4722d2343cbd0d81cb2aacc95d0c9461.zip
Restore stale session check and move after dispatch development cleanups before the request
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/dispatcher.rb7
-rw-r--r--actionpack/lib/action_controller/session/abstract_store.rb25
2 files changed, 24 insertions, 8 deletions
diff --git a/actionpack/lib/action_controller/dispatcher.rb b/actionpack/lib/action_controller/dispatcher.rb
index 781bc48887..9374a7f060 100644
--- a/actionpack/lib/action_controller/dispatcher.rb
+++ b/actionpack/lib/action_controller/dispatcher.rb
@@ -7,7 +7,6 @@ module ActionController
unless cache_classes
# Development mode callbacks
before_dispatch :reload_application
- after_dispatch :cleanup_application
ActionView::Helpers::AssetTagHelper.cache_asset_timestamps = false
end
@@ -93,11 +92,9 @@ module ActionController
run_callbacks :prepare_dispatch
Routing::Routes.reload
- end
- # Cleanup the application by clearing out loaded classes so they can
- # be reloaded on the next request without restarting the server.
- def cleanup_application
+ # Cleanup the application by clearing out loaded classes so they can
+ # be reloaded on the next request without restarting the server.
ActiveRecord::Base.reset_subclasses if defined?(ActiveRecord)
ActiveSupport::Dependencies.clear
ActiveRecord::Base.clear_reloadable_connections! if defined?(ActiveRecord)
diff --git a/actionpack/lib/action_controller/session/abstract_store.rb b/actionpack/lib/action_controller/session/abstract_store.rb
index 9434c2e05e..41a35f867f 100644
--- a/actionpack/lib/action_controller/session/abstract_store.rb
+++ b/actionpack/lib/action_controller/session/abstract_store.rb
@@ -58,9 +58,28 @@ module ActionController
end
def load!
- @id, session = @by.send(:load_session, @env)
- replace(session)
- @loaded = true
+ stale_session_check! do
+ @id, session = @by.send(:load_session, @env)
+ replace(session)
+ @loaded = true
+ end
+ end
+
+ def stale_session_check!
+ yield
+ rescue ArgumentError => argument_error
+ if argument_error.message =~ %r{undefined class/module ([\w:]*\w)}
+ begin
+ # Note that the regexp does not allow $1 to end with a ':'
+ $1.constantize
+ rescue LoadError, NameError => const_error
+ raise ActionController::SessionRestoreError, "Session contains objects whose class definition isn\\'t available.\nRemember to require the classes for all objects kept in the session.\n(Original exception: \#{const_error.message} [\#{const_error.class}])\n"
+ end
+
+ retry
+ else
+ raise
+ end
end
end