diff options
author | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-07 18:30:18 -0400 |
---|---|---|
committer | Mikel Lindsaar <raasdnil@gmail.com> | 2010-06-07 18:30:18 -0400 |
commit | a16fd961310d4df5bd20df5fe64b2f764d8aa471 (patch) | |
tree | 0e54acc2ae35e985cd8c8175f051e281acbd4595 /actionpack/lib/action_dispatch/middleware | |
parent | 735027e58d3000bd5d939e39deabfecef83ee20c (diff) | |
parent | d6953cbfd3b6e06eceba715c60e288b6d7db0d49 (diff) | |
download | rails-a16fd961310d4df5bd20df5fe64b2f764d8aa471.tar.gz rails-a16fd961310d4df5bd20df5fe64b2f764d8aa471.tar.bz2 rails-a16fd961310d4df5bd20df5fe64b2f764d8aa471.zip |
Merge branch 'master' of git://github.com/rails/rails
Diffstat (limited to 'actionpack/lib/action_dispatch/middleware')
5 files changed, 12 insertions, 20 deletions
diff --git a/actionpack/lib/action_dispatch/middleware/flash.rb b/actionpack/lib/action_dispatch/middleware/flash.rb index adde183cdb..18771fe782 100644 --- a/actionpack/lib/action_dispatch/middleware/flash.rb +++ b/actionpack/lib/action_dispatch/middleware/flash.rb @@ -176,7 +176,7 @@ module ActionDispatch @app.call(env) ensure - if (session = env['rack.session']) && (flash = session['flash']) && flash.empty? + if (session = env['rack.session']) && session.key?('flash') && session['flash'].empty? session.delete('flash') end end diff --git a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb index 15493cd2eb..3e8d64b0c6 100644 --- a/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb +++ b/actionpack/lib/action_dispatch/middleware/session/abstract_store.rb @@ -51,11 +51,11 @@ module ActionDispatch super end - private - def loaded? - @loaded - end + def loaded? + @loaded + end + private def load! stale_session_check! do id, session = @by.send(:load_session, @env) diff --git a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb index 2dd2ec9fe9..f9e81a02d3 100644 --- a/actionpack/lib/action_dispatch/middleware/show_exceptions.rb +++ b/actionpack/lib/action_dispatch/middleware/show_exceptions.rb @@ -72,7 +72,7 @@ module ActionDispatch rescue_action_in_public(exception) end rescue Exception => failsafe_error - $stderr.puts "Error during failsafe response: #{failsafe_error}" + $stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}" FAILSAFE_RESPONSE end diff --git a/actionpack/lib/action_dispatch/middleware/stack.rb b/actionpack/lib/action_dispatch/middleware/stack.rb index e3180dba77..4240e7a5d5 100644 --- a/actionpack/lib/action_dispatch/middleware/stack.rb +++ b/actionpack/lib/action_dispatch/middleware/stack.rb @@ -5,13 +5,13 @@ module ActionDispatch class Middleware attr_reader :args, :block - def initialize(klass, *args, &block) - @klass, @args, @block = klass, args, block + def initialize(klass_or_name, *args, &block) + @ref = ActiveSupport::Dependencies::Reference.new(klass_or_name) + @args, @block = args, block end def klass - return @klass if @klass.respond_to?(:new) - @klass = ActiveSupport::Inflector.constantize(@klass.to_s) + @ref.get end def ==(middleware) @@ -21,11 +21,7 @@ module ActionDispatch when Class klass == middleware else - if lazy_compare?(@klass) && lazy_compare?(middleware) - normalize(@klass) == normalize(middleware) - else - klass.name == normalize(middleware.to_s) - end + normalize(@ref.name) == normalize(middleware) end end @@ -39,10 +35,6 @@ module ActionDispatch private - def lazy_compare?(object) - object.is_a?(String) || object.is_a?(Symbol) - end - def normalize(object) object.to_s.strip.sub(/^::/, '') end diff --git a/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb b/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb index 09ff052fd0..e963b04524 100644 --- a/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb +++ b/actionpack/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb @@ -13,7 +13,7 @@ request_dump = clean_params.empty? ? 'None' : clean_params.inspect.gsub(',', ",\n") def debug_hash(hash) - hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect}" }.join("\n") + hash.sort_by { |k, v| k.to_s }.map { |k, v| "#{k}: #{v.inspect rescue $!.message}" }.join("\n") end %> |