From 917428bcce7bb22241bfc07daa5d0ddf9d107775 Mon Sep 17 00:00:00 2001 From: Gabe da Silveira Date: Fri, 14 Nov 2008 01:14:02 -0800 Subject: Make optimized named routes respect all reserved options and tie it into UrlRewriter::RESERVED_OPTIONS so it's DRY Signed-off-by: Michael Koziarski --- actionpack/lib/action_controller/routing/optimisations.rb | 8 ++------ actionpack/lib/action_controller/routing/route_set.rb | 1 + 2 files changed, 3 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/routing/optimisations.rb b/actionpack/lib/action_controller/routing/optimisations.rb index 0a87303bda..4522ebcb1a 100644 --- a/actionpack/lib/action_controller/routing/optimisations.rb +++ b/actionpack/lib/action_controller/routing/optimisations.rb @@ -106,12 +106,8 @@ module ActionController # argument class PositionalArgumentsWithAdditionalParams < PositionalArguments def guard_conditions - [ - "args.size == #{route.segment_keys.size + 1}", - "!args.last.has_key?(:anchor)", - "!args.last.has_key?(:port)", - "!args.last.has_key?(:host)" - ] + ["args.size == #{route.segment_keys.size + 1}"] + + UrlRewriter::RESERVED_OPTIONS.collect{ |key| "!args.last.has_key?(:#{key})" } end # This case uses almost the same code as positional arguments, diff --git a/actionpack/lib/action_controller/routing/route_set.rb b/actionpack/lib/action_controller/routing/route_set.rb index ff448490e9..1b8b52ad10 100644 --- a/actionpack/lib/action_controller/routing/route_set.rb +++ b/actionpack/lib/action_controller/routing/route_set.rb @@ -168,6 +168,7 @@ module ActionController # @module.module_eval <<-end_eval # We use module_eval to avoid leaks def #{selector}(*args) + #{generate_optimisation_block(route, kind)} opts = if args.empty? || Hash === args.first -- cgit v1.2.3 From 291d199de1271c254c44b94766d13013b222a125 Mon Sep 17 00:00:00 2001 From: Hiroshi Saito Date: Sun, 16 Nov 2008 17:51:39 +0900 Subject: Let polymorphic_path treat an array contains single name as without array [#1386 state:committed] Signed-off-by: David Heinemeier Hansson --- actionpack/lib/action_controller/polymorphic_routes.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/polymorphic_routes.rb b/actionpack/lib/action_controller/polymorphic_routes.rb index 2644c7f7c7..28722c93ca 100644 --- a/actionpack/lib/action_controller/polymorphic_routes.rb +++ b/actionpack/lib/action_controller/polymorphic_routes.rb @@ -74,6 +74,7 @@ module ActionController def polymorphic_url(record_or_hash_or_array, options = {}) if record_or_hash_or_array.kind_of?(Array) record_or_hash_or_array = record_or_hash_or_array.compact + record_or_hash_or_array = record_or_hash_or_array[0] if record_or_hash_or_array.size == 1 end record = extract_record(record_or_hash_or_array) -- cgit v1.2.3 From 27c03e69e94655482b0d77d3ae0ca902ce537f8c Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 19 Nov 2008 17:41:55 +0530 Subject: Remove deprecated render_component. Please use the plugin from http://github.com/rails/render_component/tree/master --- actionpack/lib/action_controller/base.rb | 2 +- actionpack/lib/action_controller/components.rb | 169 ------------------------- actionpack/lib/action_controller/flash.rb | 2 +- 3 files changed, 2 insertions(+), 171 deletions(-) delete mode 100644 actionpack/lib/action_controller/components.rb (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index f35c42f929..bffe6efa15 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -529,7 +529,7 @@ module ActionController #:nodoc: end def send_response - response.prepare! unless component_request? + response.prepare! response end diff --git a/actionpack/lib/action_controller/components.rb b/actionpack/lib/action_controller/components.rb deleted file mode 100644 index f446b91e7e..0000000000 --- a/actionpack/lib/action_controller/components.rb +++ /dev/null @@ -1,169 +0,0 @@ -module ActionController #:nodoc: - # Components allow you to call other actions for their rendered response while executing another action. You can either delegate - # the entire response rendering or you can mix a partial response in with your other content. - # - # class WeblogController < ActionController::Base - # # Performs a method and then lets hello_world output its render - # def delegate_action - # do_other_stuff_before_hello_world - # render_component :controller => "greeter", :action => "hello_world", :params => { :person => "david" } - # end - # end - # - # class GreeterController < ActionController::Base - # def hello_world - # render :text => "#{params[:person]} says, Hello World!" - # end - # end - # - # The same can be done in a view to do a partial rendering: - # - # Let's see a greeting: - # <%= render_component :controller => "greeter", :action => "hello_world" %> - # - # It is also possible to specify the controller as a class constant, bypassing the inflector - # code to compute the controller class at runtime: - # - # <%= render_component :controller => GreeterController, :action => "hello_world" %> - # - # == When to use components - # - # Components should be used with care. They're significantly slower than simply splitting reusable parts into partials and - # conceptually more complicated. Don't use components as a way of separating concerns inside a single application. Instead, - # reserve components to those rare cases where you truly have reusable view and controller elements that can be employed - # across many applications at once. - # - # So to repeat: Components are a special-purpose approach that can often be replaced with better use of partials and filters. - module Components - def self.included(base) #:nodoc: - base.class_eval do - include InstanceMethods - include ActiveSupport::Deprecation - extend ClassMethods - helper HelperMethods - - # If this controller was instantiated to process a component request, - # +parent_controller+ points to the instantiator of this controller. - attr_accessor :parent_controller - - alias_method_chain :process_cleanup, :components - alias_method_chain :set_session_options, :components - alias_method_chain :flash, :components - - alias_method :component_request?, :parent_controller - end - end - - module ClassMethods - # Track parent controller to identify component requests - def process_with_components(request, response, parent_controller = nil) #:nodoc: - controller = new - controller.parent_controller = parent_controller - controller.process(request, response) - end - end - - module HelperMethods - def render_component(options) - @controller.__send__(:render_component_as_string, options) - end - end - - module InstanceMethods - # Extracts the action_name from the request parameters and performs that action. - def process_with_components(request, response, method = :perform_action, *arguments) #:nodoc: - flash.discard if component_request? - process_without_components(request, response, method, *arguments) - end - - protected - # Renders the component specified as the response for the current method - def render_component(options) #:doc: - component_logging(options) do - render_for_text(component_response(options, true).body, response.headers["Status"]) - end - end - deprecate :render_component => "Please install render_component plugin from http://github.com/rails/render_component/tree/master" - - # Returns the component response as a string - def render_component_as_string(options) #:doc: - component_logging(options) do - response = component_response(options, false) - - if redirected = response.redirected_to - render_component_as_string(redirected) - else - response.body - end - end - end - deprecate :render_component_as_string => "Please install render_component plugin from http://github.com/rails/render_component/tree/master" - - def flash_with_components(refresh = false) #:nodoc: - if !defined?(@_flash) || refresh - @_flash = - if defined?(@parent_controller) - @parent_controller.flash - else - flash_without_components - end - end - @_flash - end - - private - def component_response(options, reuse_response) - klass = component_class(options) - request = request_for_component(klass.controller_name, options) - new_response = reuse_response ? response : response.dup - - klass.process_with_components(request, new_response, self) - end - - # determine the controller class for the component request - def component_class(options) - if controller = options[:controller] - controller.is_a?(Class) ? controller : "#{controller.camelize}Controller".constantize - else - self.class - end - end - - # Create a new request object based on the current request. - # The new request inherits the session from the current request, - # bypassing any session options set for the component controller's class - def request_for_component(controller_name, options) - new_request = request.dup - new_request.session = request.session - - new_request.instance_variable_set( - :@parameters, - (options[:params] || {}).with_indifferent_access.update( - "controller" => controller_name, "action" => options[:action], "id" => options[:id] - ) - ) - - new_request - end - - def component_logging(options) - if logger - logger.info "Start rendering component (#{options.inspect}): " - result = yield - logger.info "\n\nEnd of component rendering" - result - else - yield - end - end - - def set_session_options_with_components(request) - set_session_options_without_components(request) unless component_request? - end - - def process_cleanup_with_components - process_cleanup_without_components unless component_request? - end - end - end -end diff --git a/actionpack/lib/action_controller/flash.rb b/actionpack/lib/action_controller/flash.rb index 0148fb5c04..62fa381a6f 100644 --- a/actionpack/lib/action_controller/flash.rb +++ b/actionpack/lib/action_controller/flash.rb @@ -165,7 +165,7 @@ module ActionController #:nodoc: def assign_shortcuts_with_flash(request, response) #:nodoc: assign_shortcuts_without_flash(request, response) flash(:refresh) - flash.sweep if @_session && !component_request? + flash.sweep if @_session end end end -- cgit v1.2.3 From aeae79dc450598d2e12d5b38472d6dd2b1a4abd7 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Wed, 19 Nov 2008 22:25:08 +0530 Subject: Remove deprecated ActionController::Base#assign_default_content_type_and_charset --- actionpack/lib/action_controller/base.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index bffe6efa15..ad6562024a 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -1270,11 +1270,6 @@ module ActionController #:nodoc: @action_name = (params['action'] || 'index') end - def assign_default_content_type_and_charset - response.assign_default_content_type_and_charset! - end - deprecate :assign_default_content_type_and_charset => :'response.assign_default_content_type_and_charset!' - def action_methods self.class.action_methods end -- cgit v1.2.3 From 3be9134d1cb882f4be3be8d57b2f8bde5ecde887 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Tue, 28 Oct 2008 05:19:10 +0530 Subject: Simplify benchmarking and rescue --- actionpack/lib/action_controller/base.rb | 16 +++- actionpack/lib/action_controller/benchmarking.rb | 105 +++++++++++------------ actionpack/lib/action_controller/rescue.rb | 10 --- 3 files changed, 63 insertions(+), 68 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index ad6562024a..9c10c9a1d6 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -264,7 +264,7 @@ module ActionController #:nodoc: # Controller specific instance variables which will not be accessible inside views. @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller @action_name @before_filter_chain_aborted @action_cache_path @_session @_cookies @_headers @_params - @_flash @_response) + @_flash @_response @_runtime) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, # and images to a dedicated asset server away from the main web server. Example: @@ -862,6 +862,9 @@ module ActionController #:nodoc: # # render :xml => post.to_xml, :status => :created, :location => post_url(post) def render(options = nil, extra_options = {}, &block) #:doc: + start = Time.now + reset_db_runtime + raise DoubleRenderError, "Can only render or redirect once per action" if performed? if options.nil? @@ -940,6 +943,9 @@ module ActionController #:nodoc: render_for_file(default_template_name, options[:status], layout) end end + ensure + @_runtime[:render] = Time.now - start + log_render_benchmark end # Renders according to the same rules as render, but returns the result in a string instead @@ -1208,6 +1214,7 @@ module ActionController #:nodoc: @template = @_response.template @_headers = @_response.headers + @_runtime = {} end def initialize_current_url @@ -1249,6 +1256,8 @@ module ActionController #:nodoc: end def perform_action + start = Time.now + if action_methods.include?(action_name) send(action_name) default_render unless performed? @@ -1260,6 +1269,11 @@ module ActionController #:nodoc: else raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence}", caller end + rescue Exception => exception + rescue_action(exception) + ensure + @_runtime[:perform_action] = Time.now - start + log_benchmarks end def performed? diff --git a/actionpack/lib/action_controller/benchmarking.rb b/actionpack/lib/action_controller/benchmarking.rb index fa572ebf3d..e0a52c14f3 100644 --- a/actionpack/lib/action_controller/benchmarking.rb +++ b/actionpack/lib/action_controller/benchmarking.rb @@ -6,11 +6,6 @@ module ActionController #:nodoc: module Benchmarking #:nodoc: def self.included(base) base.extend(ClassMethods) - - base.class_eval do - alias_method_chain :perform_action, :benchmark - alias_method_chain :render, :benchmark - end end module ClassMethods @@ -40,68 +35,64 @@ module ActionController #:nodoc: end end - protected - def render_with_benchmark(options = nil, extra_options = {}, &block) - if logger - if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - db_runtime = ActiveRecord::Base.connection.reset_runtime - end + private - render_output = nil - @view_runtime = Benchmark::realtime { render_output = render_without_benchmark(options, extra_options, &block) } + def log_benchmarks + return unless logger - if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - @db_rt_before_render = db_runtime - @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime - @view_runtime -= @db_rt_after_render - end + seconds = [ @_runtime[:perform_action], 0.0001 ].max + logging_view = @_runtime.has_key?(:render) + logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - render_output - else - render_without_benchmark(options, extra_options, &block) - end - end + log_message = "Completed in #{sprintf("%.0f", seconds * 1000)}ms" - private - def perform_action_with_benchmark - if logger - seconds = [ Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001 ].max - logging_view = defined?(@view_runtime) - logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - - log_message = "Completed in #{sprintf("%.0f", seconds * 1000)}ms" - - if logging_view || logging_active_record - log_message << " (" - log_message << view_runtime if logging_view - - if logging_active_record - log_message << ", " if logging_view - log_message << active_record_runtime + ")" - else - ")" - end - end - - log_message << " | #{headers["Status"]}" - log_message << " [#{complete_request_uri rescue "unknown"}]" - - logger.info(log_message) - response.headers["X-Runtime"] = "#{sprintf("%.0f", seconds * 1000)}ms" + if logging_view || logging_active_record + log_message << " (" + log_message << view_runtime if logging_view + + if logging_active_record + log_message << ", " if logging_view + log_message << active_record_runtime + ")" else - perform_action_without_benchmark + ")" end end - def view_runtime - "View: %.0f" % (@view_runtime * 1000) + log_message << " | #{headers["Status"]}" + log_message << " [#{complete_request_uri rescue "unknown"}]" + + logger.info(log_message) + response.headers["X-Runtime"] = "#{sprintf("%.0f", seconds * 1000)}ms" + end + + def view_runtime + "View: %.0f" % (@_runtime[:render] * 1000) + end + + def active_record_runtime + db_runtime = ActiveRecord::Base.connection.reset_runtime + + if @_runtime[:db_before_render] + db_runtime += @_runtime[:db_before_render] + db_runtime += @_runtime[:db_after_render] + end + + "DB: %.0f" % (db_runtime * 1000) + end + + def log_render_benchmark + return unless logger + + if @_runtime.has_key?(:db_before_render) + @_runtime[:db_after_render] = ActiveRecord::Base.connection.reset_runtime + @_runtime[:render] -= @_runtime[:db_after_render] end + end - def active_record_runtime - db_runtime = ActiveRecord::Base.connection.reset_runtime - db_runtime += @db_rt_before_render if @db_rt_before_render - db_runtime += @db_rt_after_render if @db_rt_after_render - "DB: %.0f" % (db_runtime * 1000) + def reset_db_runtime + if logger && Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? + @_runtime[:db_before_render] = ActiveRecord::Base.connection.reset_runtime end + end end end diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index ec8e9b92d5..628190d606 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -43,10 +43,6 @@ module ActionController #:nodoc: base.extend(ClassMethods) base.send :include, ActiveSupport::Rescuable - - base.class_eval do - alias_method_chain :perform_action, :rescue - end end module ClassMethods @@ -132,12 +128,6 @@ module ActionController #:nodoc: end private - def perform_action_with_rescue #:nodoc: - perform_action_without_rescue - rescue Exception => exception - rescue_action(exception) - end - def rescues_path(template_name) "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.erb" end -- cgit v1.2.3 From dbbaccbcda7475766919723dda53c0f92afddc4b Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 20 Nov 2008 04:50:34 +0530 Subject: Revert "Simplify benchmarking and rescue". Need a different approach. This reverts commit 3be9134d1cb882f4be3be8d57b2f8bde5ecde887. --- actionpack/lib/action_controller/base.rb | 16 +--- actionpack/lib/action_controller/benchmarking.rb | 105 ++++++++++++----------- actionpack/lib/action_controller/rescue.rb | 10 +++ 3 files changed, 68 insertions(+), 63 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 9c10c9a1d6..ad6562024a 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -264,7 +264,7 @@ module ActionController #:nodoc: # Controller specific instance variables which will not be accessible inside views. @@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller @action_name @before_filter_chain_aborted @action_cache_path @_session @_cookies @_headers @_params - @_flash @_response @_runtime) + @_flash @_response) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, # and images to a dedicated asset server away from the main web server. Example: @@ -862,9 +862,6 @@ module ActionController #:nodoc: # # render :xml => post.to_xml, :status => :created, :location => post_url(post) def render(options = nil, extra_options = {}, &block) #:doc: - start = Time.now - reset_db_runtime - raise DoubleRenderError, "Can only render or redirect once per action" if performed? if options.nil? @@ -943,9 +940,6 @@ module ActionController #:nodoc: render_for_file(default_template_name, options[:status], layout) end end - ensure - @_runtime[:render] = Time.now - start - log_render_benchmark end # Renders according to the same rules as render, but returns the result in a string instead @@ -1214,7 +1208,6 @@ module ActionController #:nodoc: @template = @_response.template @_headers = @_response.headers - @_runtime = {} end def initialize_current_url @@ -1256,8 +1249,6 @@ module ActionController #:nodoc: end def perform_action - start = Time.now - if action_methods.include?(action_name) send(action_name) default_render unless performed? @@ -1269,11 +1260,6 @@ module ActionController #:nodoc: else raise UnknownAction, "No action responded to #{action_name}. Actions: #{action_methods.sort.to_sentence}", caller end - rescue Exception => exception - rescue_action(exception) - ensure - @_runtime[:perform_action] = Time.now - start - log_benchmarks end def performed? diff --git a/actionpack/lib/action_controller/benchmarking.rb b/actionpack/lib/action_controller/benchmarking.rb index e0a52c14f3..fa572ebf3d 100644 --- a/actionpack/lib/action_controller/benchmarking.rb +++ b/actionpack/lib/action_controller/benchmarking.rb @@ -6,6 +6,11 @@ module ActionController #:nodoc: module Benchmarking #:nodoc: def self.included(base) base.extend(ClassMethods) + + base.class_eval do + alias_method_chain :perform_action, :benchmark + alias_method_chain :render, :benchmark + end end module ClassMethods @@ -35,64 +40,68 @@ module ActionController #:nodoc: end end - private - - def log_benchmarks - return unless logger - - seconds = [ @_runtime[:perform_action], 0.0001 ].max - logging_view = @_runtime.has_key?(:render) - logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? + protected + def render_with_benchmark(options = nil, extra_options = {}, &block) + if logger + if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? + db_runtime = ActiveRecord::Base.connection.reset_runtime + end - log_message = "Completed in #{sprintf("%.0f", seconds * 1000)}ms" + render_output = nil + @view_runtime = Benchmark::realtime { render_output = render_without_benchmark(options, extra_options, &block) } - if logging_view || logging_active_record - log_message << " (" - log_message << view_runtime if logging_view + if Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? + @db_rt_before_render = db_runtime + @db_rt_after_render = ActiveRecord::Base.connection.reset_runtime + @view_runtime -= @db_rt_after_render + end - if logging_active_record - log_message << ", " if logging_view - log_message << active_record_runtime + ")" + render_output else - ")" + render_without_benchmark(options, extra_options, &block) end - end - - log_message << " | #{headers["Status"]}" - log_message << " [#{complete_request_uri rescue "unknown"}]" - - logger.info(log_message) - response.headers["X-Runtime"] = "#{sprintf("%.0f", seconds * 1000)}ms" - end - - def view_runtime - "View: %.0f" % (@_runtime[:render] * 1000) - end - - def active_record_runtime - db_runtime = ActiveRecord::Base.connection.reset_runtime + end - if @_runtime[:db_before_render] - db_runtime += @_runtime[:db_before_render] - db_runtime += @_runtime[:db_after_render] + private + def perform_action_with_benchmark + if logger + seconds = [ Benchmark::measure{ perform_action_without_benchmark }.real, 0.0001 ].max + logging_view = defined?(@view_runtime) + logging_active_record = Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? + + log_message = "Completed in #{sprintf("%.0f", seconds * 1000)}ms" + + if logging_view || logging_active_record + log_message << " (" + log_message << view_runtime if logging_view + + if logging_active_record + log_message << ", " if logging_view + log_message << active_record_runtime + ")" + else + ")" + end + end + + log_message << " | #{headers["Status"]}" + log_message << " [#{complete_request_uri rescue "unknown"}]" + + logger.info(log_message) + response.headers["X-Runtime"] = "#{sprintf("%.0f", seconds * 1000)}ms" + else + perform_action_without_benchmark + end end - "DB: %.0f" % (db_runtime * 1000) - end - - def log_render_benchmark - return unless logger - - if @_runtime.has_key?(:db_before_render) - @_runtime[:db_after_render] = ActiveRecord::Base.connection.reset_runtime - @_runtime[:render] -= @_runtime[:db_after_render] + def view_runtime + "View: %.0f" % (@view_runtime * 1000) end - end - def reset_db_runtime - if logger && Object.const_defined?("ActiveRecord") && ActiveRecord::Base.connected? - @_runtime[:db_before_render] = ActiveRecord::Base.connection.reset_runtime + def active_record_runtime + db_runtime = ActiveRecord::Base.connection.reset_runtime + db_runtime += @db_rt_before_render if @db_rt_before_render + db_runtime += @db_rt_after_render if @db_rt_after_render + "DB: %.0f" % (db_runtime * 1000) end - end end end diff --git a/actionpack/lib/action_controller/rescue.rb b/actionpack/lib/action_controller/rescue.rb index 628190d606..ec8e9b92d5 100644 --- a/actionpack/lib/action_controller/rescue.rb +++ b/actionpack/lib/action_controller/rescue.rb @@ -43,6 +43,10 @@ module ActionController #:nodoc: base.extend(ClassMethods) base.send :include, ActiveSupport::Rescuable + + base.class_eval do + alias_method_chain :perform_action, :rescue + end end module ClassMethods @@ -128,6 +132,12 @@ module ActionController #:nodoc: end private + def perform_action_with_rescue #:nodoc: + perform_action_without_rescue + rescue Exception => exception + rescue_action(exception) + end + def rescues_path(template_name) "#{File.dirname(__FILE__)}/templates/rescues/#{template_name}.erb" end -- cgit v1.2.3