Skip to content

Commit

Permalink
Fixed that a SessionRestoreError was thrown if a model object was pla…
Browse files Browse the repository at this point in the history
…ced 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
  • Loading branch information
dhh committed Jul 6, 2005
1 parent ac38081 commit 8dbaae6
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions actionpack/lib/action_controller/cgi_process.rb
Expand Up @@ -89,18 +89,28 @@ def host

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

Expand Down

0 comments on commit 8dbaae6

Please sign in to comment.