From 0a132c2fe13fb2b8d5dade9cf6abd70601376287 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 22 Apr 2009 17:16:28 -0700 Subject: Refactor ActionView::Path * Decouple from ActionController and ActionMailer * Bring back localization support. * Prepare to decouple templates from the filesystem. * Prepare to decouple localization from ActionView * Fix ActionMailer to take advantage of ActionView::Path --- actionpack/lib/action_controller/base/layout.rb | 2 +- actionpack/lib/action_controller/base/render.rb | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/layout.rb b/actionpack/lib/action_controller/base/layout.rb index 4fcef6c5d9..1ad5191c73 100644 --- a/actionpack/lib/action_controller/base/layout.rb +++ b/actionpack/lib/action_controller/base/layout.rb @@ -182,7 +182,7 @@ module ActionController #:nodoc: def memoized_find_layout(layout, formats) #:nodoc: return layout if layout.nil? || layout.respond_to?(:render) prefix = layout.to_s =~ /layouts\// ? nil : "layouts" - view_paths.find_by_parts(layout.to_s, formats, prefix) + view_paths.find_by_parts(layout.to_s, {:formats => formats}, prefix) end def find_layout(*args) diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 606df58518..52934076e6 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -374,8 +374,13 @@ module ActionController render_for_file(name.sub(/^\//, ''), [layout, true], options) end end - + + # ==== Arguments + # parts:: + # Example: ["show", [:html, :xml], "users", false] def render_for_parts(parts, layout, options = {}) + parts[1] = {:formats => parts[1], :locales => [I18n.locale]} + tmp = view_paths.find_by_parts(*parts) layout = _pick_layout(*layout) unless tmp.exempt_from_layout? -- cgit v1.2.3 From 3c4c6bd0df598f865f49a983b4c65c415af4bcfc Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 23 Apr 2009 00:08:40 -0700 Subject: * Add pluggable JSON backends with support for the JSON gem. [rick] Example: ActiveSupport::JSON.backend = "JSONGem" All internal Rails JSON encoding is now handled by ActiveSupport::JSON.encode(). Use of #to_json is not recommended, as it may clash with other libraries that overwrite it. However, you can recover Rails specific functionality if you really want to use #to_json. gem 'json' ActiveSupport::JSON.backend = "JSONGem" class ActiveRecord::Base alias to_json rails_to_json end --- actionpack/lib/action_controller/base/render.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 52934076e6..33695cd78e 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -254,7 +254,7 @@ module ActionController render_for_text(js) elsif json = options[:json] - json = json.to_json unless json.is_a?(String) + json = ActiveSupport::JSON.encode(json) unless json.is_a?(String) json = "#{options[:callback]}(#{json})" unless options[:callback].blank? response.content_type ||= Mime::JSON render_for_text(json) -- cgit v1.2.3 From 04949096797a390105c7ab9fb9b99938d5921dd4 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 26 Apr 2009 14:33:57 -0500 Subject: Inherit TestSession from Session::AbstractStore and add indifferent access to Session::AbstractStore. --- actionpack/lib/action_controller/base/base.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 3000b3d12f..afb9fb71cb 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -811,14 +811,8 @@ module ActionController #:nodoc: end def assign_shortcuts(request, response) - @_request, @_params = request, request.parameters - - @_response = response - @_response.session = request.session - - @_session = @_response.session - - @_headers = @_response.headers + @_request, @_response, @_params = request, response, request.parameters + @_session, @_headers = @_request.session, @_response.headers end def initialize_current_url -- cgit v1.2.3 From 5cef0cbad2d1df013c74ab96c16cf7fd84040f46 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Sun, 26 Apr 2009 19:08:04 -0700 Subject: Check for to_str rather than String --- actionpack/lib/action_controller/base/render.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 33695cd78e..601c5429c3 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -254,7 +254,7 @@ module ActionController render_for_text(js) elsif json = options[:json] - json = ActiveSupport::JSON.encode(json) unless json.is_a?(String) + json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str) json = "#{options[:callback]}(#{json})" unless options[:callback].blank? response.content_type ||= Mime::JSON render_for_text(json) -- cgit v1.2.3 From 21aa32692caf91f56d1c5c411baae635fa398344 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Mon, 27 Apr 2009 13:11:17 -0500 Subject: Delegate controller.session to request.session and deprecate response session --- actionpack/lib/action_controller/base/base.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index afb9fb71cb..1d0738588d 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -238,7 +238,7 @@ module ActionController #:nodoc: cattr_reader :protected_instance_variables # 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 @_headers @_params + @action_name @before_filter_chain_aborted @action_cache_path @_headers @_params @_flash @_response) # Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets, @@ -356,7 +356,9 @@ module ActionController #:nodoc: # Holds a hash of objects in the session. Accessed like session[:person] to get the object tied to the "person" # key. The session will hold any type of object as values, but the key should be a string or symbol. - attr_internal :session + def session + request.session + end # Holds a hash of header names and values. Accessed like headers["Cache-Control"] to get the value of the Cache-Control # directive. Values should always be specified as strings. @@ -787,7 +789,6 @@ module ActionController #:nodoc: # Resets the session by clearing out all the objects stored within and initializing a new session object. def reset_session #:doc: request.reset_session - @_session = request.session end private @@ -812,7 +813,7 @@ module ActionController #:nodoc: def assign_shortcuts(request, response) @_request, @_response, @_params = request, response, request.parameters - @_session, @_headers = @_request.session, @_response.headers + @_headers = @_response.headers end def initialize_current_url @@ -888,10 +889,6 @@ module ActionController #:nodoc: "#{request.protocol}#{request.host}#{request.request_uri}" end - def close_session - # @_session.close if @_session && @_session.respond_to?(:close) - end - def default_template(action_name = self.action_name) self.view_paths.find_template(default_template_name(action_name), default_template_format) end @@ -915,7 +912,6 @@ module ActionController #:nodoc: end def process_cleanup - close_session end end -- cgit v1.2.3 From cecafc52ee0a4a53c903ddbaba95683261f88e5f Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 23 Apr 2009 15:58:38 -0700 Subject: Refactor ActionView::Template ActionView::Template is now completely independent from template storage, which allows different back ends such as the database. ActionView::Template's only responsibility is to take in the template source (passed in from ActionView::Path), compile it, and render it. --- actionpack/lib/action_controller/base/base.rb | 20 +++++++++++++++----- actionpack/lib/action_controller/base/render.rb | 7 ++++--- 2 files changed, 19 insertions(+), 8 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 1d0738588d..2063df54b4 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -494,8 +494,18 @@ module ActionController #:nodoc: end protected :filter_parameters end + + @@exempt_from_layout = [ActionView::TemplateHandlers::RJS] + + def exempt_from_layout(*types) + types.each do |type| + @@exempt_from_layout << + ActionView::Template.handler_class_for_extension(type) + end + + @@exempt_from_layout + end - delegate :exempt_from_layout, :to => 'ActionView::Template' end public @@ -856,13 +866,13 @@ module ActionController #:nodoc: return (performed? ? ret : default_render) if called begin - default_render - rescue ActionView::MissingTemplate => e - raise e unless e.action_name == action_name - # If the path is the same as the action_name, the action is completely missing + view_paths.find_by_parts(action_name, {:formats => formats, :locales => [I18n.locale]}, controller_path) + rescue => e raise UnknownAction, "No action responded to #{action_name}. Actions: " + "#{action_methods.sort.to_sentence}", caller end + + default_render end # Returns true if a render or redirect has already been performed. diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 601c5429c3..4286577ec5 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -378,13 +378,14 @@ module ActionController # ==== Arguments # parts:: # Example: ["show", [:html, :xml], "users", false] - def render_for_parts(parts, layout, options = {}) + def render_for_parts(parts, layout_details, options = {}) parts[1] = {:formats => parts[1], :locales => [I18n.locale]} tmp = view_paths.find_by_parts(*parts) - layout = _pick_layout(*layout) unless tmp.exempt_from_layout? - + layout = _pick_layout(*layout_details) unless + self.class.exempt_from_layout.include?(tmp.handler) + render_for_text( @template._render_template_with_layout(tmp, layout, options, parts[3])) end -- cgit v1.2.3 From c0a372ba87f556769b98a6d06e8c684c3c3156df Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Tue, 28 Apr 2009 23:29:29 -0500 Subject: Deprecate template, session, assigns, and layout accessors on response object. Instead access them through the controller instance. This mainly affects functional test assertions. --- actionpack/lib/action_controller/base/base.rb | 4 +++- actionpack/lib/action_controller/base/mime_responds.rb | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 2063df54b4..14c4339c94 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -367,6 +367,8 @@ module ActionController #:nodoc: # Returns the name of the action this controller is processing. attr_accessor :action_name + attr_reader :template + class << self def call(env) # HACK: For global rescue to have access to the original request and response @@ -816,7 +818,7 @@ module ActionController #:nodoc: def initialize_template_class(response) @template = response.template = ActionView::Base.new(self.class.view_paths, {}, self, formats) - response.template.helpers.send :include, self.class.master_helper_module + @template.helpers.send :include, self.class.master_helper_module response.redirected_to = nil @performed_render = @performed_redirect = false end diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index bac225ab2a..1003e61a0b 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -127,7 +127,7 @@ module ActionController #:nodoc: @order << mime_type @responses[mime_type] ||= Proc.new do - @response.template.formats = [mime_type.to_sym] + @controller.template.formats = [mime_type.to_sym] @response.content_type = mime_type.to_s block_given? ? block.call : @controller.send(:render, :action => @controller.action_name) end -- cgit v1.2.3 From 00d1a57e9f99a1b2439281cb741fd82ef47a5c55 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 30 Apr 2009 17:26:03 -0500 Subject: Start moving TestRequest and TestResponse into ActionDispatch --- actionpack/lib/action_controller/base/base.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 14c4339c94..99b5963891 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -817,7 +817,8 @@ module ActionController #:nodoc: end def initialize_template_class(response) - @template = response.template = ActionView::Base.new(self.class.view_paths, {}, self, formats) + @template = ActionView::Base.new(self.class.view_paths, {}, self, formats) + response.template = @template if response.respond_to?(:template=) @template.helpers.send :include, self.class.master_helper_module response.redirected_to = nil @performed_render = @performed_redirect = false -- cgit v1.2.3 From f0b9e2861943d32ca73a53ab5fb6f86d10c89b04 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Thu, 30 Apr 2009 16:34:00 -0700 Subject: Fix render :json => nil [#2589 state:resolved] --- actionpack/lib/action_controller/base/render.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/render.rb b/actionpack/lib/action_controller/base/render.rb index 4286577ec5..cc0d878e01 100644 --- a/actionpack/lib/action_controller/base/render.rb +++ b/actionpack/lib/action_controller/base/render.rb @@ -253,7 +253,8 @@ module ActionController response.content_type ||= Mime::JS render_for_text(js) - elsif json = options[:json] + elsif options.include?(:json) + json = options[:json] json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str) json = "#{options[:callback]}(#{json})" unless options[:callback].blank? response.content_type ||= Mime::JSON -- cgit v1.2.3 From 72160d9f89481ea60c8268ff026099f07b1e5ed6 Mon Sep 17 00:00:00 2001 From: Yehuda Katz Date: Sat, 2 May 2009 02:15:09 -0700 Subject: Implement FooController.action(:name) * Rails actions are now Rack endpoints, and can be retrieved via FooController.action(name) and called with an env * Updated some tests that relied on the old internal #process/#call implementation --- actionpack/lib/action_controller/base/base.rb | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 99b5963891..243b7f8ae3 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -370,18 +370,18 @@ module ActionController #:nodoc: attr_reader :template class << self - def call(env) - # HACK: For global rescue to have access to the original request and response - request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env) - response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new - process(request, response) - end - - # Factory for the standard create, process loop where the controller is discarded after processing. - def process(request, response) #:nodoc: - new.process(request, response) + def action(name = nil) + @actions ||= {} + @actions[name] ||= proc do |env| + controller = new + # HACK: For global rescue to have access to the original request and response + request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env) + response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new + controller.action_name = name && name.to_s + controller.process(request, response).to_a + end end - + # Converts the class name from something like "OneModule::TwoModule::NeatController" to "NeatController". def controller_class_name @controller_class_name ||= name.demodulize @@ -518,7 +518,6 @@ module ActionController #:nodoc: assign_shortcuts(request, response) initialize_template_class(response) initialize_current_url - assign_names log_processing send(method, *arguments) @@ -883,10 +882,6 @@ module ActionController #:nodoc: @performed_render || @performed_redirect end - def assign_names - @action_name = (params['action'] || 'index') - end - def reset_variables_added_to_assigns @template.instance_variable_set("@assigns_added", nil) end -- cgit v1.2.3 From 3900f4007ee6463b8936af23c04017a900673866 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 2 May 2009 14:23:44 -0500 Subject: Deprecate assert_redirect_to's partial hash matching --- actionpack/lib/action_controller/base/base.rb | 1 - actionpack/lib/action_controller/base/redirect.rb | 4 ---- 2 files changed, 5 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 99b5963891..ef97986c0e 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -820,7 +820,6 @@ module ActionController #:nodoc: @template = ActionView::Base.new(self.class.view_paths, {}, self, formats) response.template = @template if response.respond_to?(:template=) @template.helpers.send :include, self.class.master_helper_module - response.redirected_to = nil @performed_render = @performed_redirect = false end diff --git a/actionpack/lib/action_controller/base/redirect.rb b/actionpack/lib/action_controller/base/redirect.rb index 2e92117e7c..4849caac0a 100644 --- a/actionpack/lib/action_controller/base/redirect.rb +++ b/actionpack/lib/action_controller/base/redirect.rb @@ -48,8 +48,6 @@ module ActionController status = 302 end - response.redirected_to = options - case options # The scheme name consist of a letter followed by any combination of # letters, digits, and the plus ("+"), period ("."), or hyphen ("-") @@ -82,8 +80,6 @@ module ActionController # The response body is not reset here, see +erase_render_results+ def erase_redirect_results #:nodoc: @performed_redirect = false - response.redirected_to = nil - response.redirected_to_method_params = nil response.status = DEFAULT_RENDER_STATUS_CODE response.headers.delete('Location') end -- cgit v1.2.3 From f32cf44870549c6cc5b6e6c84cffc1facf6ec38e Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 2 May 2009 15:29:18 -0500 Subject: Switch functional tests to run through the rack interface instead of process --- actionpack/lib/action_controller/base/base.rb | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index ef97986c0e..eb65f59ddd 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -371,10 +371,7 @@ module ActionController #:nodoc: class << self def call(env) - # HACK: For global rescue to have access to the original request and response - request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env) - response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new - process(request, response) + new.call(env) end # Factory for the standard create, process loop where the controller is discarded after processing. @@ -511,6 +508,13 @@ module ActionController #:nodoc: end public + def call(env) + # HACK: For global rescue to have access to the original request and response + request = env["action_dispatch.rescue.request"] ||= ActionDispatch::Request.new(env) + response = env["action_dispatch.rescue.response"] ||= ActionDispatch::Response.new + process(request, response).to_a + end + # Extracts the action_name from the request parameters and performs that action. def process(request, response, method = :perform_action, *arguments) #:nodoc: response.request = request -- cgit v1.2.3 From 24affdc88c4a4af03ce1ec5b23c3def18b90effe Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 2 May 2009 15:37:29 -0500 Subject: Deprecate Controller.process interface --- actionpack/lib/action_controller/base/base.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index eb65f59ddd..60567454b1 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -376,6 +376,7 @@ module ActionController #:nodoc: # Factory for the standard create, process loop where the controller is discarded after processing. def process(request, response) #:nodoc: + ActiveSupport::Deprecation.warn("Controller.process has been deprecated. Use Controller.call instead", caller) new.process(request, response) end -- cgit v1.2.3 From 11af089cee0a0e744e267d32becfe2c66a586d31 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sat, 2 May 2009 23:02:22 -0500 Subject: Extract ActionController rescue templates into Rescue and ShowExceptions middleware. This commit breaks all exception catching plugins like ExceptionNotifier. These plugins should be rewritten as middleware instead overriding Controller#rescue_action_in_public. --- actionpack/lib/action_controller/base/base.rb | 9 +---- actionpack/lib/action_controller/base/rescue.rb | 50 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) create mode 100644 actionpack/lib/action_controller/base/rescue.rb (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 60567454b1..7bbde519cc 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -30,10 +30,6 @@ module ActionController #:nodoc: def allowed_methods_header allowed_methods.map { |method_symbol| method_symbol.to_s.upcase } * ', ' end - - def handle_response!(response) - response.headers['Allow'] ||= allowed_methods_header - end end class NotImplemented < MethodNotAllowed #:nodoc: @@ -510,9 +506,8 @@ module ActionController #:nodoc: public def call(env) - # HACK: For global rescue to have access to the original request and response - request = env["action_dispatch.rescue.request"] ||= ActionDispatch::Request.new(env) - response = env["action_dispatch.rescue.response"] ||= ActionDispatch::Response.new + request = ActionDispatch::Request.new(env) + response = ActionDispatch::Response.new process(request, response).to_a end diff --git a/actionpack/lib/action_controller/base/rescue.rb b/actionpack/lib/action_controller/base/rescue.rb new file mode 100644 index 0000000000..2717a06a37 --- /dev/null +++ b/actionpack/lib/action_controller/base/rescue.rb @@ -0,0 +1,50 @@ +module ActionController #:nodoc: + # Actions that fail to perform as expected throw exceptions. These + # exceptions can either be rescued for the public view (with a nice + # user-friendly explanation) or for the developers view (with tons of + # debugging information). The developers view is already implemented by + # the Action Controller, but the public view should be tailored to your + # specific application. + # + # The default behavior for public exceptions is to render a static html + # file with the name of the error code thrown. If no such file exists, an + # empty response is sent with the correct status code. + # + # You can override what constitutes a local request by overriding the + # local_request? method in your own controller. Custom rescue + # behavior is achieved by overriding the rescue_action_in_public + # and rescue_action_locally methods. + module Rescue + def self.included(base) #:nodoc: + base.send :include, ActiveSupport::Rescuable + base.extend(ClassMethods) + + base.class_eval do + alias_method_chain :perform_action, :rescue + end + end + + module ClassMethods + def rescue_action(env) + exception = env.delete('action_dispatch.rescue.exception') + request = ActionDispatch::Request.new(env) + response = ActionDispatch::Response.new + new.process(request, response, :rescue_action, exception).to_a + end + end + + protected + # Exception handler called when the performance of an action raises + # an exception. + def rescue_action(exception) + rescue_with_handler(exception) || raise(exception) + end + + private + def perform_action_with_rescue + perform_action_without_rescue + rescue Exception => exception + rescue_action(exception) + end + end +end -- cgit v1.2.3 From 216309c16519d94a9e0aebf758029a78696ab8d6 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Tue, 12 May 2009 16:21:34 -0700 Subject: Implemented redirects and partial rendering in new base. --- actionpack/lib/action_controller/base/redirect.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/redirect.rb b/actionpack/lib/action_controller/base/redirect.rb index 4849caac0a..7e10f614e2 100644 --- a/actionpack/lib/action_controller/base/redirect.rb +++ b/actionpack/lib/action_controller/base/redirect.rb @@ -70,7 +70,9 @@ module ActionController def redirect_to_full_url(url, status) raise DoubleRenderError if performed? logger.info("Redirected to #{url}") if logger && logger.info? - response.redirect(url, interpret_status(status)) + response.status = interpret_status(status) + response.location = url.gsub(/[\r\n]/, '') + response.body = "You are being redirected." @performed_redirect = true end -- cgit v1.2.3 From e8550ee0329586b32de425e905c7af7e65bc78a8 Mon Sep 17 00:00:00 2001 From: Jeremy Kemper Date: Wed, 13 May 2009 01:10:37 -0700 Subject: Cherry-pick core extensions --- actionpack/lib/action_controller/base/base.rb | 2 ++ actionpack/lib/action_controller/base/chained/benchmarking.rb | 2 +- actionpack/lib/action_controller/base/http_authentication.rb | 6 ++++-- actionpack/lib/action_controller/base/layout.rb | 4 ++++ 4 files changed, 11 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index d25801b17b..2813e71d12 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -1,5 +1,7 @@ require 'action_controller/deprecated' require 'set' +require 'active_support/core_ext/class/inheritable_attributes' +require 'active_support/core_ext/module/attr_internal' module ActionController #:nodoc: class ActionControllerError < StandardError #:nodoc: diff --git a/actionpack/lib/action_controller/base/chained/benchmarking.rb b/actionpack/lib/action_controller/base/chained/benchmarking.rb index 066150f58a..66e9e9c31d 100644 --- a/actionpack/lib/action_controller/base/chained/benchmarking.rb +++ b/actionpack/lib/action_controller/base/chained/benchmarking.rb @@ -1,4 +1,4 @@ -require 'benchmark' +require 'active_support/core_ext/benchmark' module ActionController #:nodoc: # The benchmarking module times the performance of actions and reports to the logger. If the Active Record diff --git a/actionpack/lib/action_controller/base/http_authentication.rb b/actionpack/lib/action_controller/base/http_authentication.rb index b6b5267c66..fa8ecea408 100644 --- a/actionpack/lib/action_controller/base/http_authentication.rb +++ b/actionpack/lib/action_controller/base/http_authentication.rb @@ -1,3 +1,5 @@ +require 'active_support/base64' + module ActionController module HttpAuthentication # Makes it dead easy to do HTTP Basic authentication. @@ -276,7 +278,7 @@ module ActionController t = time.to_i hashed = [t, secret_key] digest = ::Digest::MD5.hexdigest(hashed.join(":")) - Base64.encode64("#{t}:#{digest}").gsub("\n", '') + ActiveSupport::Base64.encode64("#{t}:#{digest}").gsub("\n", '') end # Might want a shorter timeout depending on whether the request @@ -285,7 +287,7 @@ module ActionController # allow a user to use new nonce without prompting user again for their # username and password. def validate_nonce(request, value, seconds_to_timeout=5*60) - t = Base64.decode64(value).split(":").first.to_i + t = ActiveSupport::Base64.decode64(value).split(":").first.to_i nonce(t) == value && (t - Time.now.to_i).abs <= seconds_to_timeout end diff --git a/actionpack/lib/action_controller/base/layout.rb b/actionpack/lib/action_controller/base/layout.rb index 1ad5191c73..cf5f46a32b 100644 --- a/actionpack/lib/action_controller/base/layout.rb +++ b/actionpack/lib/action_controller/base/layout.rb @@ -1,3 +1,7 @@ +require 'active_support/core_ext/enumerable' +require 'active_support/core_ext/class/delegating_attributes' +require 'active_support/core_ext/class/inheritable_attributes' + module ActionController #:nodoc: module Layout #:nodoc: def self.included(base) -- cgit v1.2.3 From 5a45446cff0daf4ca747257a8779dcd5d9cae1d7 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Fri, 15 May 2009 17:49:11 -0700 Subject: Ported Rescuable to new base --- actionpack/lib/action_controller/base/chained/filters.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/filters.rb b/actionpack/lib/action_controller/base/chained/filters.rb index 9022b8b279..98fe306fd5 100644 --- a/actionpack/lib/action_controller/base/chained/filters.rb +++ b/actionpack/lib/action_controller/base/chained/filters.rb @@ -160,7 +160,7 @@ module ActionController #:nodoc: def convert_only_and_except_options_to_sets_of_strings(opts) [:only, :except].each do |key| if values = opts[key] - opts[key] = Array(values).map(&:to_s).to_set + opts[key] = Array(values).map {|val| val.to_s }.to_set end end end -- cgit v1.2.3 From e41984c5f7f38b62c05dfcb54940bf51f6961aeb Mon Sep 17 00:00:00 2001 From: "Thomas E. Glasgow" Date: Sun, 17 May 2009 18:54:34 +0200 Subject: Simplify filter_chain method implementation [#2327 state:resolved] Signed-off-by: Pratik Naik --- actionpack/lib/action_controller/base/chained/filters.rb | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/filters.rb b/actionpack/lib/action_controller/base/chained/filters.rb index 98fe306fd5..e121c0129d 100644 --- a/actionpack/lib/action_controller/base/chained/filters.rb +++ b/actionpack/lib/action_controller/base/chained/filters.rb @@ -571,12 +571,7 @@ module ActionController #:nodoc: # Returns an array of Filter objects for this controller. def filter_chain - if chain = read_inheritable_attribute('filter_chain') - return chain - else - write_inheritable_attribute('filter_chain', FilterChain.new) - return filter_chain - end + read_inheritable_attribute('filter_chain') || write_inheritable_attribute('filter_chain', FilterChain.new) end # Returns all the before filters for this class and all its ancestors. -- cgit v1.2.3 From c3319504f066c9362b4b30e1e15bbd1cadde8e25 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Sun, 17 May 2009 11:09:14 -0500 Subject: Rescue hack was supposed to be removed. Some how it crept back in. --- actionpack/lib/action_controller/base/base.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 2813e71d12..c59068c628 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -368,9 +368,8 @@ module ActionController #:nodoc: attr_reader :template def action(name, env) - # HACK: For global rescue to have access to the original request and response - request = env["action_controller.rescue.request"] ||= ActionDispatch::Request.new(env) - response = env["action_controller.rescue.response"] ||= ActionDispatch::Response.new + request = ActionDispatch::Request.new(env) + response = ActionDispatch::Response.new self.action_name = name && name.to_s process(request, response).to_a end -- cgit v1.2.3 From 195fadbfd31294d43634afb7bbf4f0ffc86b470a Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Mon, 18 May 2009 16:59:37 +0200 Subject: Ensure HTTP Digest auth uses appropriate HTTP method [#2490 state:resolved] [Steve Madsen] --- actionpack/lib/action_controller/base/http_authentication.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/http_authentication.rb b/actionpack/lib/action_controller/base/http_authentication.rb index fa8ecea408..2893290efb 100644 --- a/actionpack/lib/action_controller/base/http_authentication.rb +++ b/actionpack/lib/action_controller/base/http_authentication.rb @@ -194,9 +194,10 @@ module ActionController if valid_nonce && realm == credentials[:realm] && opaque == credentials[:opaque] password = password_procedure.call(credentials[:username]) + method = request.env['rack.methodoverride.original_method'] || request.env['REQUEST_METHOD'] [true, false].any? do |password_is_ha1| - expected = expected_response(request.env['REQUEST_METHOD'], request.env['REQUEST_URI'], credentials, password, password_is_ha1) + expected = expected_response(method, request.env['REQUEST_URI'], credentials, password, password_is_ha1) expected == credentials[:response] end end -- cgit v1.2.3 From 07f733c6315980bde120c98c6b8a25e2773ee6bf Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Mon, 18 May 2009 16:15:43 -0700 Subject: Ported simple benchmarking in new base --- actionpack/lib/action_controller/base/chained/benchmarking.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/benchmarking.rb b/actionpack/lib/action_controller/base/chained/benchmarking.rb index 66e9e9c31d..57a1ac8314 100644 --- a/actionpack/lib/action_controller/base/chained/benchmarking.rb +++ b/actionpack/lib/action_controller/base/chained/benchmarking.rb @@ -21,7 +21,7 @@ module ActionController #:nodoc: # easy to include benchmarking statements in production software that will remain inexpensive because the benchmark # will only be conducted if the log level is low enough. def benchmark(title, log_level = Logger::DEBUG, use_silence = true) - if logger && logger.level == log_level + if logger && logger.level >= log_level result = nil ms = Benchmark.ms { result = use_silence ? silence { yield } : yield } logger.add(log_level, "#{title} (#{('%.1f' % ms)}ms)") -- cgit v1.2.3 From 01f032f256f96f65e154061b582fbb4b32e4a692 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Wed, 20 May 2009 15:33:08 -0700 Subject: Added responds_to to new base. --- .../lib/action_controller/base/mime_responds.rb | 215 ++++++++++----------- 1 file changed, 107 insertions(+), 108 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index 1003e61a0b..e560376e0d 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -1,111 +1,103 @@ module ActionController #:nodoc: module MimeResponds #:nodoc: - def self.included(base) - base.module_eval do - include ActionController::MimeResponds::InstanceMethods - end - end - - module InstanceMethods - # Without web-service support, an action which collects the data for displaying a list of people - # might look something like this: - # - # def index - # @people = Person.find(:all) - # end - # - # Here's the same action, with web-service support baked in: - # - # def index - # @people = Person.find(:all) - # - # respond_to do |format| - # format.html - # format.xml { render :xml => @people.to_xml } - # end - # end - # - # What that says is, "if the client wants HTML in response to this action, just respond as we - # would have before, but if the client wants XML, return them the list of people in XML format." - # (Rails determines the desired response format from the HTTP Accept header submitted by the client.) - # - # Supposing you have an action that adds a new person, optionally creating their company - # (by name) if it does not already exist, without web-services, it might look like this: - # - # def create - # @company = Company.find_or_create_by_name(params[:company][:name]) - # @person = @company.people.create(params[:person]) - # - # redirect_to(person_list_url) - # end - # - # Here's the same action, with web-service support baked in: - # - # def create - # company = params[:person].delete(:company) - # @company = Company.find_or_create_by_name(company[:name]) - # @person = @company.people.create(params[:person]) - # - # respond_to do |format| - # format.html { redirect_to(person_list_url) } - # format.js - # format.xml { render :xml => @person.to_xml(:include => @company) } - # end - # end - # - # If the client wants HTML, we just redirect them back to the person list. If they want Javascript - # (format.js), then it is an RJS request and we render the RJS template associated with this action. - # Lastly, if the client wants XML, we render the created person as XML, but with a twist: we also - # include the person's company in the rendered XML, so you get something like this: - # - # - # ... - # ... - # - # ... - # ... - # ... - # - # - # - # Note, however, the extra bit at the top of that action: - # - # company = params[:person].delete(:company) - # @company = Company.find_or_create_by_name(company[:name]) - # - # This is because the incoming XML document (if a web-service request is in process) can only contain a - # single root-node. So, we have to rearrange things so that the request looks like this (url-encoded): - # - # person[name]=...&person[company][name]=...&... - # - # And, like this (xml-encoded): - # - # - # ... - # - # ... - # - # - # - # In other words, we make the request so that it operates on a single entity's person. Then, in the action, - # we extract the company data from the request, find or create the company, and then create the new person - # with the remaining data. - # - # Note that you can define your own XML parameter parser which would allow you to describe multiple entities - # in a single request (i.e., by wrapping them all in a single root node), but if you just go with the flow - # and accept Rails' defaults, life will be much easier. - # - # If you need to use a MIME type which isn't supported by default, you can register your own handlers in - # environment.rb as follows. - # - # Mime::Type.register "image/jpg", :jpg - def respond_to(*types, &block) - raise ArgumentError, "respond_to takes either types or a block, never both" unless types.any? ^ block - block ||= lambda { |responder| types.each { |type| responder.send(type) } } - responder = Responder.new(self) - block.call(responder) - responder.respond - end + # Without web-service support, an action which collects the data for displaying a list of people + # might look something like this: + # + # def index + # @people = Person.find(:all) + # end + # + # Here's the same action, with web-service support baked in: + # + # def index + # @people = Person.find(:all) + # + # respond_to do |format| + # format.html + # format.xml { render :xml => @people.to_xml } + # end + # end + # + # What that says is, "if the client wants HTML in response to this action, just respond as we + # would have before, but if the client wants XML, return them the list of people in XML format." + # (Rails determines the desired response format from the HTTP Accept header submitted by the client.) + # + # Supposing you have an action that adds a new person, optionally creating their company + # (by name) if it does not already exist, without web-services, it might look like this: + # + # def create + # @company = Company.find_or_create_by_name(params[:company][:name]) + # @person = @company.people.create(params[:person]) + # + # redirect_to(person_list_url) + # end + # + # Here's the same action, with web-service support baked in: + # + # def create + # company = params[:person].delete(:company) + # @company = Company.find_or_create_by_name(company[:name]) + # @person = @company.people.create(params[:person]) + # + # respond_to do |format| + # format.html { redirect_to(person_list_url) } + # format.js + # format.xml { render :xml => @person.to_xml(:include => @company) } + # end + # end + # + # If the client wants HTML, we just redirect them back to the person list. If they want Javascript + # (format.js), then it is an RJS request and we render the RJS template associated with this action. + # Lastly, if the client wants XML, we render the created person as XML, but with a twist: we also + # include the person's company in the rendered XML, so you get something like this: + # + # + # ... + # ... + # + # ... + # ... + # ... + # + # + # + # Note, however, the extra bit at the top of that action: + # + # company = params[:person].delete(:company) + # @company = Company.find_or_create_by_name(company[:name]) + # + # This is because the incoming XML document (if a web-service request is in process) can only contain a + # single root-node. So, we have to rearrange things so that the request looks like this (url-encoded): + # + # person[name]=...&person[company][name]=...&... + # + # And, like this (xml-encoded): + # + # + # ... + # + # ... + # + # + # + # In other words, we make the request so that it operates on a single entity's person. Then, in the action, + # we extract the company data from the request, find or create the company, and then create the new person + # with the remaining data. + # + # Note that you can define your own XML parameter parser which would allow you to describe multiple entities + # in a single request (i.e., by wrapping them all in a single root node), but if you just go with the flow + # and accept Rails' defaults, life will be much easier. + # + # If you need to use a MIME type which isn't supported by default, you can register your own handlers in + # environment.rb as follows. + # + # Mime::Type.register "image/jpg", :jpg + def respond_to(*types, &block) + raise ArgumentError, "respond_to takes either types or a block, never both" unless types.any? ^ block + block ||= lambda { |responder| types.each { |type| responder.send(type) } } + responder = Responder.new(self) + block.call(responder) + responder.respond end class Responder #:nodoc: @@ -127,8 +119,15 @@ module ActionController #:nodoc: @order << mime_type @responses[mime_type] ||= Proc.new do - @controller.template.formats = [mime_type.to_sym] - @response.content_type = mime_type.to_s + # TODO: Remove this when new base is merged in + if defined?(Http) + @controller.formats = [mime_type.to_sym] + @controller.template.formats = [mime_type.to_sym] + else + @controller.template.formats = [mime_type.to_sym] + @response.content_type = mime_type.to_s + end + block_given? ? block.call : @controller.send(:render, :action => @controller.action_name) end end -- cgit v1.2.3 From 8e7a87d299483fce6af3be89e50deae43055a96f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 01:38:48 +0200 Subject: Make ActionController::Flash work with new_base --- .../lib/action_controller/base/chained/flash.rb | 74 +++++++++++++++------- 1 file changed, 52 insertions(+), 22 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/flash.rb b/actionpack/lib/action_controller/base/chained/flash.rb index 56ee9c67e2..6bd482d85a 100644 --- a/actionpack/lib/action_controller/base/chained/flash.rb +++ b/actionpack/lib/action_controller/base/chained/flash.rb @@ -26,9 +26,18 @@ module ActionController #:nodoc: # # See docs on the FlashHash class for more details about the flash. module Flash - def self.included(base) - base.class_eval do - include InstanceMethods + extend ActiveSupport::DependencyModule + + # TODO : Remove the defined? check when new base is the main base + depends_on Session if defined?(ActionController::Http) + + included do + # TODO : Remove the defined? check when new base is the main base + if defined?(ActionController::Http) + include InstanceMethodsForNewBase + else + include InstanceMethodsForBase + alias_method_chain :perform_action, :flash alias_method_chain :reset_session, :flash end @@ -135,29 +144,50 @@ module ActionController #:nodoc: end end - module InstanceMethods #:nodoc: + module InstanceMethodsForBase #:nodoc: protected - def perform_action_with_flash - perform_action_without_flash - remove_instance_variable(:@_flash) if defined? @_flash - end - def reset_session_with_flash - reset_session_without_flash - remove_instance_variable(:@_flash) if defined? @_flash - end + def perform_action_with_flash + perform_action_without_flash + remove_instance_variable(:@_flash) if defined?(@_flash) + end - # Access the contents of the flash. Use flash["notice"] to - # read a notice you put there or flash["notice"] = "hello" - # to put a new one. - def flash #:doc: - unless defined? @_flash - @_flash = session["flash"] ||= FlashHash.new - @_flash.sweep - end + def reset_session_with_flash + reset_session_without_flash + remove_instance_variable(:@_flash) if defined?(@_flash) + end + end - @_flash - end + module InstanceMethodsForNewBase #:nodoc: + protected + + def reset_session + super + remove_flash_instance_variable + end + + def process_action(method_name) + super + remove_flash_instance_variable + end + + def remove_flash_instance_variable + remove_instance_variable(:@_flash) if defined?(@_flash) + end + end + + protected + + # Access the contents of the flash. Use flash["notice"] to + # read a notice you put there or flash["notice"] = "hello" + # to put a new one. + def flash #:doc: + unless defined?(@_flash) + @_flash = session["flash"] ||= FlashHash.new + @_flash.sweep + end + + @_flash end end end -- cgit v1.2.3 From e21d1614bb9006e69bf4bb2467b823aa12e64485 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 02:55:25 +0200 Subject: Made ActionController::Verification work with new_base --- actionpack/lib/action_controller/base/verification.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index c62b81b666..a513e9f40c 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -1,7 +1,13 @@ module ActionController #:nodoc: module Verification #:nodoc: - def self.included(base) #:nodoc: - base.extend(ClassMethods) + extend ActiveSupport::DependencyModule + + # TODO : Remove the defined? check when new base is the main base + if defined?(ActionController::Http) + depends_on AbstractController::Callbacks + depends_on Session + depends_on Flash + depends_on Renderer end # This module provides a class-level method for specifying that certain @@ -102,7 +108,7 @@ module ActionController #:nodoc: end def verify_presence_of_keys_in_hash_flash_or_params(options) # :nodoc: - [*options[:params] ].find { |v| params[v].nil? } || + [*options[:params] ].find { |v| v && params[v.to_sym].nil? } || [*options[:session]].find { |v| session[v].nil? } || [*options[:flash] ].find { |v| flash[v].nil? } end -- cgit v1.2.3 From 5a036457620b7fb22027dc4f0c399871db6ed0c3 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 03:04:17 +0200 Subject: Allow Module#depends_on to accept multiple modules --- actionpack/lib/action_controller/base/verification.rb | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index a513e9f40c..3fa5a105b1 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -4,10 +4,7 @@ module ActionController #:nodoc: # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) - depends_on AbstractController::Callbacks - depends_on Session - depends_on Flash - depends_on Renderer + depends_on AbstractController::Callbacks, Session, Flash, Renderer end # This module provides a class-level method for specifying that certain -- cgit v1.2.3 From 59b32f2883b58a1e7bf2c246801a605b673e3fb6 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 11:50:34 +0200 Subject: RequestForgeryProtection now works with the new base --- .../base/request_forgery_protection.rb | 24 +++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/base/request_forgery_protection.rb index 3067122ceb..0a0e20e1f1 100644 --- a/actionpack/lib/action_controller/base/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/base/request_forgery_protection.rb @@ -3,12 +3,26 @@ module ActionController #:nodoc: end module RequestForgeryProtection - def self.included(base) - base.class_eval do - helper_method :form_authenticity_token - helper_method :protect_against_forgery? + extend ActiveSupport::DependencyModule + + # TODO : Remove the defined? check when new base is the main base + if defined?(ActionController::Http) + depends_on AbstractController::Helpers, Session + end + + included do + if defined?(ActionController::Http) + # Sets the token parameter name for RequestForgery. Calling +protect_from_forgery+ + # sets it to :authenticity_token by default. + cattr_accessor :request_forgery_protection_token + + # Controls whether request forgergy protection is turned on or not. Turned off by default only in test mode. + class_inheritable_accessor :allow_forgery_protection + self.allow_forgery_protection = true end - base.extend(ClassMethods) + + helper_method :form_authenticity_token + helper_method :protect_against_forgery? end # Protecting controller actions from CSRF attacks by ensuring that all forms are coming from the current web application, not a -- cgit v1.2.3 From 386ff66e5ed4fbe1e060610d4226a4eb22dca766 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 21:48:26 +0200 Subject: Add Streaming to new base --- actionpack/lib/action_controller/base/streaming.rb | 1 + 1 file changed, 1 insertion(+) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index 9f80f48c3d..b69b13eea8 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -88,6 +88,7 @@ module ActionController #:nodoc: head options[:status], X_SENDFILE_HEADER => path else if options[:stream] + # TODO : Make render :text => proc {} work with the new base render :status => options[:status], :text => Proc.new { |response, output| logger.info "Streaming file #{path}" unless logger.nil? len = options[:buffer_size] || 4096 -- cgit v1.2.3 From e693f45e155a81b6c337b8766870b56716a05105 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Thu, 21 May 2009 14:22:07 -0700 Subject: Remove some response content type concepts from ActionView --- actionpack/lib/action_controller/base/mime_responds.rb | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/mime_responds.rb b/actionpack/lib/action_controller/base/mime_responds.rb index e560376e0d..3c17dda1a1 100644 --- a/actionpack/lib/action_controller/base/mime_responds.rb +++ b/actionpack/lib/action_controller/base/mime_responds.rb @@ -122,12 +122,11 @@ module ActionController #:nodoc: # TODO: Remove this when new base is merged in if defined?(Http) @controller.formats = [mime_type.to_sym] - @controller.template.formats = [mime_type.to_sym] - else - @controller.template.formats = [mime_type.to_sym] - @response.content_type = mime_type.to_s end + @controller.template.formats = [mime_type.to_sym] + @response.content_type = mime_type.to_s + block_given? ? block.call : @controller.send(:render, :action => @controller.action_name) end end -- cgit v1.2.3 From d2cac9dd0e28b99bd45fd9eaa1d5a6b3dee8fa8f Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Thu, 21 May 2009 22:03:52 +0200 Subject: Add missing dependency in Streaming --- actionpack/lib/action_controller/base/streaming.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index b69b13eea8..5872ba99a2 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -2,6 +2,13 @@ module ActionController #:nodoc: # Methods for sending arbitrary data and for streaming files to the browser, # instead of rendering. module Streaming + extend ActiveSupport::DependencyModule + + # TODO : Remove the defined? check when new base is the main base + if defined?(ActionController::Http) + depends_on ActionController::Renderer + end + DEFAULT_SEND_FILE_OPTIONS = { :type => 'application/octet-stream'.freeze, :disposition => 'attachment'.freeze, -- cgit v1.2.3 From 1d168afcb146872cb7e49b6d513629fbb19e39b0 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Fri, 22 May 2009 19:51:11 +0200 Subject: Move FilterParameterLogging to a stand alone module and make it work on new base --- actionpack/lib/action_controller/base/base.rb | 58 +------------ .../base/filter_parameter_logging.rb | 97 ++++++++++++++++++++++ 2 files changed, 98 insertions(+), 57 deletions(-) create mode 100644 actionpack/lib/action_controller/base/filter_parameter_logging.rb (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index c59068c628..2586037965 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -448,55 +448,6 @@ module ActionController #:nodoc: @view_paths = superclass.view_paths.dup if @view_paths.nil? @view_paths.push(*path) end - - # Replace sensitive parameter data from the request log. - # Filters parameters that have any of the arguments as a substring. - # Looks in all subhashes of the param hash for keys to filter. - # If a block is given, each key and value of the parameter hash and all - # subhashes is passed to it, the value or key - # can be replaced using String#replace or similar method. - # - # Examples: - # filter_parameter_logging - # => Does nothing, just slows the logging process down - # - # filter_parameter_logging :password - # => replaces the value to all keys matching /password/i with "[FILTERED]" - # - # filter_parameter_logging :foo, "bar" - # => replaces the value to all keys matching /foo|bar/i with "[FILTERED]" - # - # filter_parameter_logging { |k,v| v.reverse! if k =~ /secret/i } - # => reverses the value to all keys matching /secret/i - # - # filter_parameter_logging(:foo, "bar") { |k,v| v.reverse! if k =~ /secret/i } - # => reverses the value to all keys matching /secret/i, and - # replaces the value to all keys matching /foo|bar/i with "[FILTERED]" - def filter_parameter_logging(*filter_words, &block) - parameter_filter = Regexp.new(filter_words.collect{ |s| s.to_s }.join('|'), true) if filter_words.length > 0 - - define_method(:filter_parameters) do |unfiltered_parameters| - filtered_parameters = {} - - unfiltered_parameters.each do |key, value| - if key =~ parameter_filter - filtered_parameters[key] = '[FILTERED]' - elsif value.is_a?(Hash) - filtered_parameters[key] = filter_parameters(value) - elsif block_given? - key = key.dup - value = value.dup if value - yield key, value - filtered_parameters[key] = value - else - filtered_parameters[key] = value - end - end - - filtered_parameters - end - protected :filter_parameters - end @@exempt_from_layout = [ActionView::TemplateHandlers::RJS] @@ -853,13 +804,6 @@ module ActionController #:nodoc: logger.info(request_id) end - def log_processing_for_parameters - parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup - parameters = parameters.except!(:controller, :action, :format, :_method) - - logger.info " Parameters: #{parameters.inspect}" unless parameters.empty? - end - def default_render #:nodoc: render end @@ -933,7 +877,7 @@ module ActionController #:nodoc: [ Filters, Layout, Renderer, Redirector, Responder, Benchmarking, Rescue, Flash, MimeResponds, Helpers, Cookies, Caching, Verification, Streaming, SessionManagement, HttpAuthentication::Basic::ControllerMethods, HttpAuthentication::Digest::ControllerMethods, RecordIdentifier, - RequestForgeryProtection, Translation + RequestForgeryProtection, Translation, FilterParameterLogging ].each do |mod| include mod end diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb new file mode 100644 index 0000000000..8e012b2a25 --- /dev/null +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -0,0 +1,97 @@ +module ActionController + module FilterParameterLogging + extend ActiveSupport::DependencyModule + + # TODO : Remove the defined? check when new base is the main base + if defined?(ActionController::Http) + depends_on AbstractController::Logger + end + + included do + if defined?(ActionController::Http) + include InstanceMethodsForNewBase + end + end + + module ClassMethods + # Replace sensitive parameter data from the request log. + # Filters parameters that have any of the arguments as a substring. + # Looks in all subhashes of the param hash for keys to filter. + # If a block is given, each key and value of the parameter hash and all + # subhashes is passed to it, the value or key + # can be replaced using String#replace or similar method. + # + # Examples: + # filter_parameter_logging + # => Does nothing, just slows the logging process down + # + # filter_parameter_logging :password + # => replaces the value to all keys matching /password/i with "[FILTERED]" + # + # filter_parameter_logging :foo, "bar" + # => replaces the value to all keys matching /foo|bar/i with "[FILTERED]" + # + # filter_parameter_logging { |k,v| v.reverse! if k =~ /secret/i } + # => reverses the value to all keys matching /secret/i + # + # filter_parameter_logging(:foo, "bar") { |k,v| v.reverse! if k =~ /secret/i } + # => reverses the value to all keys matching /secret/i, and + # replaces the value to all keys matching /foo|bar/i with "[FILTERED]" + def filter_parameter_logging(*filter_words, &block) + parameter_filter = Regexp.new(filter_words.collect{ |s| s.to_s }.join('|'), true) if filter_words.length > 0 + + define_method(:filter_parameters) do |unfiltered_parameters| + filtered_parameters = {} + + unfiltered_parameters.each do |key, value| + if key =~ parameter_filter + filtered_parameters[key] = '[FILTERED]' + elsif value.is_a?(Hash) + filtered_parameters[key] = filter_parameters(value) + elsif block_given? + key = key.dup + value = value.dup if value + yield key, value + filtered_parameters[key] = value + else + filtered_parameters[key] = value + end + end + + filtered_parameters + end + protected :filter_parameters + end + end + + module InstanceMethodsForNewBase + # TODO : Fix the order of information inside such that it's exactly same as the old base + def process(*) + ret = super + + if logger + parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup + parameters = parameters.except!(:controller, :action, :format, :_method) + + unless parameters.empty? + # TODO : Move DelayedLog to AS + log = AbstractController::Logger::DelayedLog.new { " Parameters: #{parameters.inspect}" } + logger.info(log) + end + end + + ret + end + end + + private + + # TODO : This method is not needed for the new base + def log_processing_for_parameters + parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup + parameters = parameters.except!(:controller, :action, :format, :_method) + + logger.info " Parameters: #{parameters.inspect}" unless parameters.empty? + end + end +end -- cgit v1.2.3 From e976c489e6416cdc4714721df78dd43dd6d13d99 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 23 May 2009 00:17:05 +0200 Subject: Add all the existing helpers related features to the new base --- actionpack/lib/action_controller/base/helpers.rb | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/helpers.rb b/actionpack/lib/action_controller/base/helpers.rb index ba65032f6a..96fa7896a9 100644 --- a/actionpack/lib/action_controller/base/helpers.rb +++ b/actionpack/lib/action_controller/base/helpers.rb @@ -3,23 +3,19 @@ require 'active_support/dependencies' # FIXME: helper { ... } is broken on Ruby 1.9 module ActionController #:nodoc: module Helpers #:nodoc: - def self.included(base) + extend ActiveSupport::DependencyModule + + included do # Initialize the base module to aggregate its helpers. - base.class_inheritable_accessor :master_helper_module - base.master_helper_module = Module.new + class_inheritable_accessor :master_helper_module + self.master_helper_module = Module.new # Set the default directory for helpers - base.class_inheritable_accessor :helpers_dir - base.helpers_dir = (defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/app/helpers" : "app/helpers") - - # Extend base with class methods to declare helpers. - base.extend(ClassMethods) + class_inheritable_accessor :helpers_dir + self.helpers_dir = (defined?(RAILS_ROOT) ? "#{RAILS_ROOT}/app/helpers" : "app/helpers") - base.class_eval do - # Wrap inherited to create a new master helper module for subclasses. - class << self - alias_method_chain :inherited, :helper - end + class << self + alias_method_chain :inherited, :helper end end -- cgit v1.2.3 From f766f669464fa9900197d6b3559c2e00e53de9cd Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 23 May 2009 01:36:09 +0200 Subject: Make logging_test pass with the new base --- actionpack/lib/action_controller/base/filter_parameter_logging.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb index 8e012b2a25..f5a678ca03 100644 --- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -71,7 +71,7 @@ module ActionController if logger parameters = respond_to?(:filter_parameters) ? filter_parameters(params) : params.dup - parameters = parameters.except!(:controller, :action, :format, :_method) + parameters = parameters.except!(:controller, :action, :format, :_method, :only_path) unless parameters.empty? # TODO : Move DelayedLog to AS -- cgit v1.2.3 From 3ac6d8f8b01fb04b8d6d35d75d802b41f4c256c9 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 23 May 2009 02:35:34 +0200 Subject: Remove unnecessary asset_host initialization --- actionpack/lib/action_controller/base/base.rb | 1 - 1 file changed, 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/base.rb b/actionpack/lib/action_controller/base/base.rb index 2586037965..67369eb122 100644 --- a/actionpack/lib/action_controller/base/base.rb +++ b/actionpack/lib/action_controller/base/base.rb @@ -242,7 +242,6 @@ module ActionController #:nodoc: # 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: # ActionController::Base.asset_host = "http://assets.example.com" - @@asset_host = "" cattr_accessor :asset_host # All requests are considered local by default, so everyone will be exposed to detailed debugging screens on errors. -- cgit v1.2.3 From bb8e5843f32b13e759da51a4713a31b23ebcac6d Mon Sep 17 00:00:00 2001 From: Niels Ganser Date: Wed, 27 May 2009 14:51:33 -0500 Subject: ActionController::Flash::FlashHash.use now returns either the value corresponding to the passed key or itself when no key is passed [#1792 state:resolved] Signed-off-by: Joshua Peek --- actionpack/lib/action_controller/base/chained/flash.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/flash.rb b/actionpack/lib/action_controller/base/chained/flash.rb index 6bd482d85a..7a8dd2dcf9 100644 --- a/actionpack/lib/action_controller/base/chained/flash.rb +++ b/actionpack/lib/action_controller/base/chained/flash.rb @@ -135,12 +135,11 @@ module ActionController #:nodoc: # use('msg') # marks the "msg" entry as used # use(nil, false) # marks the entire flash as unused (keeps it around for one more action) # use('msg', false) # marks the "msg" entry as unused (keeps it around for one more action) - def use(k=nil, v=true) - unless k.nil? - @used[k] = v - else - keys.each{ |key| use(key, v) } - end + # Returns the single value for the key you asked to be marked (un)used or the FlashHash itself + # if no key is passed. + def use(key = nil, used = true) + Array(key || keys).each { |k| @used[k] = used } + return key ? self[key] : self end end -- cgit v1.2.3 From 0349278f3da9f7f532330cf295eed35ede3bae66 Mon Sep 17 00:00:00 2001 From: Olly Legg Date: Thu, 28 May 2009 09:18:27 -0500 Subject: Memoize cookies so that updates to cookies are available in the current request. [#2733 state:resolved] Signed-off-by: Joshua Peek --- actionpack/lib/action_controller/base/cookies.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/cookies.rb b/actionpack/lib/action_controller/base/cookies.rb index ca380e98d0..d4806623c3 100644 --- a/actionpack/lib/action_controller/base/cookies.rb +++ b/actionpack/lib/action_controller/base/cookies.rb @@ -51,7 +51,7 @@ module ActionController #:nodoc: protected # Returns the cookie container, which operates as described above. def cookies - CookieJar.new(self) + @cookies ||= CookieJar.new(self) end end -- cgit v1.2.3 From 72cb6f58be6590ac2590eea420a1b3ef175189b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johan=20S=C3=B6rensen?= Date: Thu, 28 May 2009 09:30:49 -0500 Subject: The FlashHash and friends causes a lot of needless session storing, when we know for a fact that there's no content in the flash. By not storing the empty hash in the session we save a lot of communication with the various session backends, while still keeping the same interface to the flash. [#2703 state:resolved] Signed-off-by: Joshua Peek --- .../lib/action_controller/base/chained/flash.rb | 70 ++++++++++++---------- 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/flash.rb b/actionpack/lib/action_controller/base/chained/flash.rb index 7a8dd2dcf9..2d084ba1ab 100644 --- a/actionpack/lib/action_controller/base/chained/flash.rb +++ b/actionpack/lib/action_controller/base/chained/flash.rb @@ -30,7 +30,7 @@ module ActionController #:nodoc: # TODO : Remove the defined? check when new base is the main base depends_on Session if defined?(ActionController::Http) - + included do # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) @@ -129,6 +129,11 @@ module ActionController #:nodoc: (@used.keys - keys).each{ |k| @used.delete(k) } end + def store(session, key = "flash") + return if self.empty? + session[key] = self + end + private # Used internally by the keep and discard methods # use() # marks the entire flash as used @@ -145,48 +150,47 @@ module ActionController #:nodoc: module InstanceMethodsForBase #:nodoc: protected + def perform_action_with_flash + perform_action_without_flash + if defined? @_flash + @_flash.store(session) + remove_instance_variable(:@_flash) + end + end - def perform_action_with_flash - perform_action_without_flash - remove_instance_variable(:@_flash) if defined?(@_flash) - end - - def reset_session_with_flash - reset_session_without_flash - remove_instance_variable(:@_flash) if defined?(@_flash) - end + def reset_session_with_flash + reset_session_without_flash + remove_instance_variable(:@_flash) if defined?(@_flash) + end end module InstanceMethodsForNewBase #:nodoc: protected + def process_action(method_name) + super + if defined? @_flash + @_flash.store(session) + remove_instance_variable(:@_flash) + end + end - def reset_session - super - remove_flash_instance_variable - end - - def process_action(method_name) - super - remove_flash_instance_variable - end - - def remove_flash_instance_variable - remove_instance_variable(:@_flash) if defined?(@_flash) - end + def reset_session + super + remove_instance_variable(:@_flash) if defined?(@_flash) + end end protected + # Access the contents of the flash. Use flash["notice"] to + # read a notice you put there or flash["notice"] = "hello" + # to put a new one. + def flash #:doc: + if !defined?(@_flash) + @_flash = session["flash"] || FlashHash.new + @_flash.sweep + end - # Access the contents of the flash. Use flash["notice"] to - # read a notice you put there or flash["notice"] = "hello" - # to put a new one. - def flash #:doc: - unless defined?(@_flash) - @_flash = session["flash"] ||= FlashHash.new - @_flash.sweep + @_flash end - - @_flash - end end end -- cgit v1.2.3 From 4e50a35fa243f6cf7ad567774a9f7c1cb87a1653 Mon Sep 17 00:00:00 2001 From: Joshua Peek Date: Thu, 28 May 2009 11:35:36 -0500 Subject: Break up DependencyModule's dual function of providing a "depend_on" DSL and "included" block DSL into separate modules. But, unify both approaches under AS::Concern. --- actionpack/lib/action_controller/base/chained/flash.rb | 2 +- actionpack/lib/action_controller/base/filter_parameter_logging.rb | 2 +- actionpack/lib/action_controller/base/helpers.rb | 2 +- actionpack/lib/action_controller/base/request_forgery_protection.rb | 2 +- actionpack/lib/action_controller/base/streaming.rb | 2 +- actionpack/lib/action_controller/base/verification.rb | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) (limited to 'actionpack/lib/action_controller/base') diff --git a/actionpack/lib/action_controller/base/chained/flash.rb b/actionpack/lib/action_controller/base/chained/flash.rb index 2d084ba1ab..04d27bf090 100644 --- a/actionpack/lib/action_controller/base/chained/flash.rb +++ b/actionpack/lib/action_controller/base/chained/flash.rb @@ -26,7 +26,7 @@ module ActionController #:nodoc: # # See docs on the FlashHash class for more details about the flash. module Flash - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base depends_on Session if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/filter_parameter_logging.rb b/actionpack/lib/action_controller/base/filter_parameter_logging.rb index f5a678ca03..9df286ee24 100644 --- a/actionpack/lib/action_controller/base/filter_parameter_logging.rb +++ b/actionpack/lib/action_controller/base/filter_parameter_logging.rb @@ -1,6 +1,6 @@ module ActionController module FilterParameterLogging - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/helpers.rb b/actionpack/lib/action_controller/base/helpers.rb index 96fa7896a9..f74158bc13 100644 --- a/actionpack/lib/action_controller/base/helpers.rb +++ b/actionpack/lib/action_controller/base/helpers.rb @@ -3,7 +3,7 @@ require 'active_support/dependencies' # FIXME: helper { ... } is broken on Ruby 1.9 module ActionController #:nodoc: module Helpers #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern included do # Initialize the base module to aggregate its helpers. diff --git a/actionpack/lib/action_controller/base/request_forgery_protection.rb b/actionpack/lib/action_controller/base/request_forgery_protection.rb index 0a0e20e1f1..368c6e9de8 100644 --- a/actionpack/lib/action_controller/base/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/base/request_forgery_protection.rb @@ -3,7 +3,7 @@ module ActionController #:nodoc: end module RequestForgeryProtection - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/streaming.rb b/actionpack/lib/action_controller/base/streaming.rb index 5872ba99a2..5f56c95483 100644 --- a/actionpack/lib/action_controller/base/streaming.rb +++ b/actionpack/lib/action_controller/base/streaming.rb @@ -2,7 +2,7 @@ module ActionController #:nodoc: # Methods for sending arbitrary data and for streaming files to the browser, # instead of rendering. module Streaming - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) diff --git a/actionpack/lib/action_controller/base/verification.rb b/actionpack/lib/action_controller/base/verification.rb index 3fa5a105b1..31654e36f3 100644 --- a/actionpack/lib/action_controller/base/verification.rb +++ b/actionpack/lib/action_controller/base/verification.rb @@ -1,6 +1,6 @@ module ActionController #:nodoc: module Verification #:nodoc: - extend ActiveSupport::DependencyModule + extend ActiveSupport::Concern # TODO : Remove the defined? check when new base is the main base if defined?(ActionController::Http) -- cgit v1.2.3