aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-07-06 07:06:02 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-07-06 07:06:02 +0000
commit8dbaae6012c8aa71c811eb42e7a7ac32a36e2080 (patch)
tree11d5c5148d326fc61e5f62e3a8b8ced0e8424c2a /actionpack
parentac380810ec6e8072963644eed519ba7e88ca0c1d (diff)
downloadrails-8dbaae6012c8aa71c811eb42e7a7ac32a36e2080.tar.gz
rails-8dbaae6012c8aa71c811eb42e7a7ac32a36e2080.tar.bz2
rails-8dbaae6012c8aa71c811eb42e7a7ac32a36e2080.zip
Fixed that a SessionRestoreError was thrown if a model object was placed in the session that wasn't available to all controllers
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1725 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/cgi_process.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/actionpack/lib/action_controller/cgi_process.rb b/actionpack/lib/action_controller/cgi_process.rb
index be37fa6dd8..2f31073055 100644
--- a/actionpack/lib/action_controller/cgi_process.rb
+++ b/actionpack/lib/action_controller/cgi_process.rb
@@ -89,18 +89,28 @@ module ActionController #:nodoc:
def session
return @session unless @session.nil?
+
begin
@session = (@session_options == false ? {} : CGI::Session.new(@cgi, session_options_with_string_keys))
@session["__valid_session"]
return @session
rescue ArgumentError => e
- @session.delete if @session
- raise(
- ActionController::SessionRestoreError,
- "Session contained objects where the class definition wasn't available. " +
- "Remember to require classes for all objects kept in the session. " +
- "The session has been deleted. (Original exception: #{e.message} [#{e.class}])"
- )
+ if e.message =~ %r{undefined class/module (\w+)}
+ begin
+ Module.const_missing($1)
+ rescue LoadError, NameError => e
+ raise(
+ ActionController::SessionRestoreError,
+ "Session contained objects where the class definition wasn't available. " +
+ "Remember to require classes for all objects kept in the session. " +
+ "(Original exception: #{e.message} [#{e.class}])"
+ )
+ end
+
+ retry
+ else
+ raise
+ end
end
end