From b4b0fddb24b0e6cbff6936606689984274cecd15 Mon Sep 17 00:00:00 2001 From: Levente Bagi Date: Tue, 6 Mar 2012 16:24:04 +0000 Subject: Don't ignore call to undefined method in Sweeper --- actionpack/lib/action_controller/caching/sweeping.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb index 49cf70ec21..808a6fe5f3 100644 --- a/actionpack/lib/action_controller/caching/sweeping.rb +++ b/actionpack/lib/action_controller/caching/sweeping.rb @@ -88,7 +88,7 @@ module ActionController #:nodoc: end def method_missing(method, *arguments, &block) - return unless @controller + super unless @controller @controller.__send__(method, *arguments, &block) end end -- cgit v1.2.3 From 245941101b1ea00a9b1af613c20b0ee994a43946 Mon Sep 17 00:00:00 2001 From: Sergey Nartimov Date: Fri, 9 Mar 2012 19:33:06 +0300 Subject: configure how unverified request will be handled can be configured using `:with` option in `protect_from_forgery` method or `request_forgery_protection_method` config option possible values: - :reset_session (default) - :exception new applications are generated with: protect_from_forgery :with => :exception --- .../metal/request_forgery_protection.rb | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/metal/request_forgery_protection.rb b/actionpack/lib/action_controller/metal/request_forgery_protection.rb index afa9243f02..3081c14c09 100644 --- a/actionpack/lib/action_controller/metal/request_forgery_protection.rb +++ b/actionpack/lib/action_controller/metal/request_forgery_protection.rb @@ -37,6 +37,10 @@ module ActionController #:nodoc: config_accessor :request_forgery_protection_token self.request_forgery_protection_token ||= :authenticity_token + # Controls how unverified request will be handled + config_accessor :request_forgery_protection_method + self.request_forgery_protection_method ||= :reset_session + # Controls whether request forgery protection is turned on or not. Turned off by default only in test mode. config_accessor :allow_forgery_protection self.allow_forgery_protection = true if allow_forgery_protection.nil? @@ -64,8 +68,10 @@ module ActionController #:nodoc: # Valid Options: # # * :only/:except - Passed to the before_filter call. Set which actions are verified. + # * :with - Set the method to handle unverified request. Valid values: :exception and :reset_session (default). def protect_from_forgery(options = {}) self.request_forgery_protection_token ||= :authenticity_token + self.request_forgery_protection_method = options.delete(:with) if options.key?(:with) prepend_before_filter :verify_authenticity_token, options end end @@ -80,9 +86,19 @@ module ActionController #:nodoc: end # This is the method that defines the application behavior when a request is found to be unverified. - # By default, \Rails resets the session when it finds an unverified request. + # By default, \Rails uses request_forgery_protection_method when it finds an unverified request: + # + # * :reset_session - Resets the session. + # * :exception: - Raises ActionController::InvalidAuthenticityToken exception. def handle_unverified_request - reset_session + case request_forgery_protection_method + when :exception + raise ActionController::InvalidAuthenticityToken + when :reset_session + reset_session + else + raise ArgumentError, 'Invalid request forgery protection method, use :exception or :reset_session' + end end # Returns true or false if a request is verified. Checks: -- cgit v1.2.3 From b142bd84d83b222fca393355cdd76416648e5625 Mon Sep 17 00:00:00 2001 From: Grant Hutchins Date: Sat, 10 Mar 2012 19:25:12 -0500 Subject: assert_template matches against Regexp This allows for more strict template assertions, while maintaining backward compatibility. For example, if you use assert_template("foo/bar") and "foo/bar/baz" was rendered, the test passes. But if you use assert_template(%r{\Afoo/bar\Z}), you will catch that a different template was rendered. Also, if you passed an unsupported argument to assert_template() in the past, it would silently succeed. Now it raises an ArgumentError. --- actionpack/lib/action_controller/test_case.rb | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index e9a3ec5a22..7af30ed690 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -56,6 +56,9 @@ module ActionController # # assert that the "new" view template was rendered # assert_template "new" # + # # assert that the exact template "admin/posts/new" was rendered + # assert_template %r{\Aadmin/posts/new\Z} + # # # assert that the "_customer" partial was rendered twice # assert_template :partial => '_customer', :count => 2 # @@ -74,11 +77,11 @@ module ActionController response.body case options - when NilClass, String, Symbol + when NilClass, String, Symbol, Regexp options = options.to_s if Symbol === options rendered = @templates msg = message || sprintf("expecting <%s> but rendering with <%s>", - options, rendered.keys) + options.inspect, rendered.keys) assert_block(msg) do if options rendered.any? { |t,num| t.match(options) } @@ -121,6 +124,8 @@ module ActionController assert @partials.empty?, "Expected no partials to be rendered" end + else + raise ArgumentError, "assert_template only accepts a String, Symbol, Hash, Regexp, or nil" end end end -- cgit v1.2.3 From fb094acc56f3b351986db35ee217caa7242d4cde Mon Sep 17 00:00:00 2001 From: Mark Thomson Date: Tue, 13 Mar 2012 02:16:38 -0500 Subject: Updated description of #retrieve_collector_from_mimes --- actionpack/lib/action_controller/metal/mime_responds.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index 800752975c..41809cf6a1 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -259,8 +259,12 @@ module ActionController #:nodoc: end end - # Collects mimes and return the response for the negotiated format. Returns - # nil if :not_acceptable was sent to the client. + # Returns a Collector object containing the appropriate mime-type response + # for the current request, based on the available responses defined by a block. + # In typical usage this is the block passed to +respond_with+ or +respond_to+. + # + # Sends :not_acceptable to the client and returns nil if no suitable format + # is available. # def retrieve_collector_from_mimes(mimes=nil, &block) #:nodoc: mimes ||= collect_mimes_from_class_level -- cgit v1.2.3 From 829e3797002c960fdd4fb0f94455dcd728a3d606 Mon Sep 17 00:00:00 2001 From: Egor Homakov Date: Tue, 13 Mar 2012 15:13:05 +0400 Subject: 'module' is reserved word. Sample of code with error - not cool. --- actionpack/lib/action_controller/base.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 95de595f4f..6ce78f34b5 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -174,8 +174,8 @@ module ActionController # Shortcut helper that returns all the ActionController modules except the ones passed in the argument: # # class MetalController - # ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |module| - # include module + # ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left| + # include left # end # end # -- cgit v1.2.3 From f1637bf2bb00490203503fbd943b73406e043d1d Mon Sep 17 00:00:00 2001 From: Prem Sichanugrist Date: Sun, 15 May 2011 15:34:36 -0400 Subject: Remove Active Resource source files from the repository Dear Active Resource, It's not that I hate you or anything, but you didn't get much attention lately. There're so many alternatives out there, and I think people have made their choice to use them than you. I think it's time for you to have a big rest, peacefully in this Git repository. I will miss you, @sikachu. --- actionpack/lib/action_controller/record_identifier.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/record_identifier.rb b/actionpack/lib/action_controller/record_identifier.rb index 9c38ff44d8..18dda978b3 100644 --- a/actionpack/lib/action_controller/record_identifier.rb +++ b/actionpack/lib/action_controller/record_identifier.rb @@ -2,8 +2,8 @@ require 'active_support/core_ext/module' module ActionController # The record identifier encapsulates a number of naming conventions for dealing with records, like Active Records or - # Active Resources or pretty much any other model type that has an id. These patterns are then used to try elevate - # the view actions to a higher logical level. Example: + # pretty much any other model type that has an id. These patterns are then used to try elevate the view actions to + # a higher logical level. Example: # # # routes # resources :posts -- cgit v1.2.3 From 4c16791f355c74f8e6ad916e67fd4ae81efbf708 Mon Sep 17 00:00:00 2001 From: Santiago Pastorino Date: Tue, 13 Mar 2012 16:21:41 -0300 Subject: Add ActionController::HTTP More info http://edgeguides.rubyonrails.org/api_app.html [Carlos Antonio da Silva & Santiago Pastorino] --- actionpack/lib/action_controller/base.rb | 2 +- actionpack/lib/action_controller/http.rb | 134 +++++++++++++++++++++ .../lib/action_controller/metal/force_ssl.rb | 2 +- actionpack/lib/action_controller/railtie.rb | 13 +- actionpack/lib/action_controller/railties/paths.rb | 1 - 5 files changed, 146 insertions(+), 6 deletions(-) create mode 100644 actionpack/lib/action_controller/http.rb (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 6ce78f34b5..71425cd542 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -171,7 +171,7 @@ module ActionController class Base < Metal abstract! - # Shortcut helper that returns all the ActionController modules except the ones passed in the argument: + # Shortcut helper that returns all the ActionController::Base modules except the ones passed in the argument: # # class MetalController # ActionController::Base.without_modules(:ParamsWrapper, :Streaming).each do |left| diff --git a/actionpack/lib/action_controller/http.rb b/actionpack/lib/action_controller/http.rb new file mode 100644 index 0000000000..252a652cd9 --- /dev/null +++ b/actionpack/lib/action_controller/http.rb @@ -0,0 +1,134 @@ +require "action_controller/log_subscriber" + +module ActionController + # HTTP Controller is a lightweight version of ActionController::Base, + # created for applications that don't require all functionality that a complete + # \Rails controller provides, allowing you to create faster controllers. The + # main scenario where HTTP Controllers could be used is API only applications. + # + # An HTTP Controller is different from a normal controller in the sense that + # by default it doesn't include a number of features that are usually required + # by browser access only: layouts and templates rendering, cookies, sessions, + # flash, assets, and so on. This makes the entire controller stack thinner and + # faster, suitable for API applications. It doesn't mean you won't have such + # features if you need them: they're all available for you to include in + # your application, they're just not part of the default HTTP Controller stack. + # + # By default, only the ApplicationController in a \Rails application inherits + # from ActionController::HTTP. All other controllers in turn inherit + # from ApplicationController. + # + # A sample controller could look like this: + # + # class PostsController < ApplicationController + # def index + # @posts = Post.all + # render json: @posts + # end + # end + # + # Request, response and parameters objects all work the exact same way as + # ActionController::Base. + # + # == Renders + # + # The default HTTP Controller stack includes all renderers, which means you + # can use render :json and brothers freely in your controllers. Keep + # in mind that templates are not going to be rendered, so you need to ensure + # your controller is calling either render or redirect in + # all actions. + # + # def show + # @post = Post.find(params[:id]) + # render json: @post + # end + # + # == Redirects + # + # Redirects are used to move from one action to another. You can use the + # redirect method in your controllers in the same way as + # ActionController::Base. For example: + # + # def create + # redirect_to root_url and return if not_authorized? + # # do stuff here + # end + # + # == Adding new behavior + # + # In some scenarios you may want to add back some functionality provided by + # ActionController::Base that is not present by default in + # ActionController::HTTP, for instance MimeResponds. This + # module gives you the respond_to and respond_with methods. + # Adding it is quite simple, you just need to include the module in a specific + # controller or in ApplicationController in case you want it + # available to your entire app: + # + # class ApplicationController < ActionController::HTTP + # include ActionController::MimeResponds + # end + # + # class PostsController < ApplicationController + # respond_to :json, :xml + # + # def index + # @posts = Post.all + # respond_with @posts + # end + # end + # + # Quite straightforward. Make sure to check ActionController::Base + # available modules if you want to include any other functionality that is + # not provided by ActionController::HTTP out of the box. + class HTTP < Metal + abstract! + + # Shortcut helper that returns all the ActionController::HTTP modules except the ones passed in the argument: + # + # class MetalController + # ActionController::HTTP.without_modules(:ParamsWrapper, :Streaming).each do |left| + # include left + # end + # end + # + # This gives better control over what you want to exclude and makes it easier + # to create a bare controller class, instead of listing the modules required manually. + def self.without_modules(*modules) + modules = modules.map do |m| + m.is_a?(Symbol) ? ActionController.const_get(m) : m + end + + MODULES - modules + end + + MODULES = [ + HideActions, + UrlFor, + Redirecting, + Rendering, + Renderers::All, + ConditionalGet, + RackDelegation, + + ForceSSL, + DataStreaming, + + # Before callbacks should also be executed the earliest as possible, so + # also include them at the bottom. + AbstractController::Callbacks, + + # Append rescue at the bottom to wrap as much as possible. + Rescue, + + # Add instrumentations hooks at the bottom, to ensure they instrument + # all the methods properly. + Instrumentation + ] + + MODULES.each do |mod| + include mod + end + + ActiveSupport.run_load_hooks(:action_controller, self) + end +end diff --git a/actionpack/lib/action_controller/metal/force_ssl.rb b/actionpack/lib/action_controller/metal/force_ssl.rb index a1e40fc4e0..ac12cbb625 100644 --- a/actionpack/lib/action_controller/metal/force_ssl.rb +++ b/actionpack/lib/action_controller/metal/force_ssl.rb @@ -44,7 +44,7 @@ module ActionController redirect_options = {:protocol => 'https://', :status => :moved_permanently} redirect_options.merge!(:host => host) if host redirect_options.merge!(:params => request.query_parameters) - flash.keep + flash.keep if respond_to?(:flash) redirect_to redirect_options end end diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 3e170d7872..5e837ca6e1 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -14,7 +14,7 @@ module ActionController end initializer "action_controller.initialize_framework_caches" do - ActiveSupport.on_load(:action_controller) { self.cache_store ||= Rails.cache } + ActiveSupport.on_load(:action_controller) { self.cache_store ||= Rails.cache if respond_to?(:cache_store) } end initializer "action_controller.assets_config", :group => :all do |app| @@ -37,8 +37,15 @@ module ActionController ActiveSupport.on_load(:action_controller) do include app.routes.mounted_helpers extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) - extend ::ActionController::Railties::Paths.with(app) - options.each { |k,v| send("#{k}=", v) } + extend ::ActionController::Railties::Paths.with(app) if respond_to?(:helpers_path) + options.each do |k,v| + k = "#{k}=" + if respond_to?(k) + send(k, v) + elsif !Base.respond_to?(k) + raise "Invalid option key: #{k}" + end + end end end diff --git a/actionpack/lib/action_controller/railties/paths.rb b/actionpack/lib/action_controller/railties/paths.rb index bbe63149ad..7e79b036ed 100644 --- a/actionpack/lib/action_controller/railties/paths.rb +++ b/actionpack/lib/action_controller/railties/paths.rb @@ -11,7 +11,6 @@ module ActionController else paths = app.helpers_paths end - klass.helpers_path = paths if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers -- cgit v1.2.3 From 6db930cb5bbff9ad824590b5844e04768de240b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Wed, 14 Mar 2012 22:30:01 +0100 Subject: Remove --http. --- actionpack/lib/action_controller/http.rb | 134 ------------------------------- 1 file changed, 134 deletions(-) delete mode 100644 actionpack/lib/action_controller/http.rb (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/http.rb b/actionpack/lib/action_controller/http.rb deleted file mode 100644 index 252a652cd9..0000000000 --- a/actionpack/lib/action_controller/http.rb +++ /dev/null @@ -1,134 +0,0 @@ -require "action_controller/log_subscriber" - -module ActionController - # HTTP Controller is a lightweight version of ActionController::Base, - # created for applications that don't require all functionality that a complete - # \Rails controller provides, allowing you to create faster controllers. The - # main scenario where HTTP Controllers could be used is API only applications. - # - # An HTTP Controller is different from a normal controller in the sense that - # by default it doesn't include a number of features that are usually required - # by browser access only: layouts and templates rendering, cookies, sessions, - # flash, assets, and so on. This makes the entire controller stack thinner and - # faster, suitable for API applications. It doesn't mean you won't have such - # features if you need them: they're all available for you to include in - # your application, they're just not part of the default HTTP Controller stack. - # - # By default, only the ApplicationController in a \Rails application inherits - # from ActionController::HTTP. All other controllers in turn inherit - # from ApplicationController. - # - # A sample controller could look like this: - # - # class PostsController < ApplicationController - # def index - # @posts = Post.all - # render json: @posts - # end - # end - # - # Request, response and parameters objects all work the exact same way as - # ActionController::Base. - # - # == Renders - # - # The default HTTP Controller stack includes all renderers, which means you - # can use render :json and brothers freely in your controllers. Keep - # in mind that templates are not going to be rendered, so you need to ensure - # your controller is calling either render or redirect in - # all actions. - # - # def show - # @post = Post.find(params[:id]) - # render json: @post - # end - # - # == Redirects - # - # Redirects are used to move from one action to another. You can use the - # redirect method in your controllers in the same way as - # ActionController::Base. For example: - # - # def create - # redirect_to root_url and return if not_authorized? - # # do stuff here - # end - # - # == Adding new behavior - # - # In some scenarios you may want to add back some functionality provided by - # ActionController::Base that is not present by default in - # ActionController::HTTP, for instance MimeResponds. This - # module gives you the respond_to and respond_with methods. - # Adding it is quite simple, you just need to include the module in a specific - # controller or in ApplicationController in case you want it - # available to your entire app: - # - # class ApplicationController < ActionController::HTTP - # include ActionController::MimeResponds - # end - # - # class PostsController < ApplicationController - # respond_to :json, :xml - # - # def index - # @posts = Post.all - # respond_with @posts - # end - # end - # - # Quite straightforward. Make sure to check ActionController::Base - # available modules if you want to include any other functionality that is - # not provided by ActionController::HTTP out of the box. - class HTTP < Metal - abstract! - - # Shortcut helper that returns all the ActionController::HTTP modules except the ones passed in the argument: - # - # class MetalController - # ActionController::HTTP.without_modules(:ParamsWrapper, :Streaming).each do |left| - # include left - # end - # end - # - # This gives better control over what you want to exclude and makes it easier - # to create a bare controller class, instead of listing the modules required manually. - def self.without_modules(*modules) - modules = modules.map do |m| - m.is_a?(Symbol) ? ActionController.const_get(m) : m - end - - MODULES - modules - end - - MODULES = [ - HideActions, - UrlFor, - Redirecting, - Rendering, - Renderers::All, - ConditionalGet, - RackDelegation, - - ForceSSL, - DataStreaming, - - # Before callbacks should also be executed the earliest as possible, so - # also include them at the bottom. - AbstractController::Callbacks, - - # Append rescue at the bottom to wrap as much as possible. - Rescue, - - # Add instrumentations hooks at the bottom, to ensure they instrument - # all the methods properly. - Instrumentation - ] - - MODULES.each do |mod| - include mod - end - - ActiveSupport.run_load_hooks(:action_controller, self) - end -end -- cgit v1.2.3 From 5b94e73d1a604c59ecd1ebb9441d60ea864fa1b5 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Thu, 15 Mar 2012 04:09:52 +0100 Subject: Remove ActionController::TestCase#rescue_action_in_public! This method has no effect since exception handling was moved to middlewares and ActionController tests do not use any middlewares. --- actionpack/lib/action_controller/test_case.rb | 5 ----- 1 file changed, 5 deletions(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb index 7af30ed690..7ba8319e4c 100644 --- a/actionpack/lib/action_controller/test_case.rb +++ b/actionpack/lib/action_controller/test_case.rb @@ -505,11 +505,6 @@ module ActionController end end - # Cause the action to be rescued according to the regular rules for rescue_action when the visitor is not local - def rescue_action_in_public! - @request.remote_addr = '208.77.188.166' # example.com - end - included do include ActionController::TemplateAssertions include ActionDispatch::Assertions -- cgit v1.2.3 From fbc9d0f44f090a9873834f4966760c3e80682559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 15 Mar 2012 08:48:38 +0100 Subject: Simplify helpers handling. Ensure Metal can run AC hooks. --- actionpack/lib/action_controller/metal/helpers.rb | 1 + actionpack/lib/action_controller/railtie.rb | 22 ++++++++++---------- .../lib/action_controller/railties/helpers.rb | 22 ++++++++++++++++++++ actionpack/lib/action_controller/railties/paths.rb | 24 ---------------------- 4 files changed, 34 insertions(+), 35 deletions(-) create mode 100644 actionpack/lib/action_controller/railties/helpers.rb delete mode 100644 actionpack/lib/action_controller/railties/paths.rb (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index d070eaae5d..1a4bca12d2 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -52,6 +52,7 @@ module ActionController module Helpers extend ActiveSupport::Concern + class << self; attr_accessor :helpers_path; end include AbstractController::Helpers included do diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 5e837ca6e1..851a2c4aee 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -3,33 +3,32 @@ require "action_controller" require "action_dispatch/railtie" require "action_view/railtie" require "abstract_controller/railties/routes_helpers" -require "action_controller/railties/paths" +require "action_controller/railties/helpers" module ActionController class Railtie < Rails::Railtie #:nodoc: config.action_controller = ActiveSupport::OrderedOptions.new - initializer "action_controller.logger" do - ActiveSupport.on_load(:action_controller) { self.logger ||= Rails.logger } - end - - initializer "action_controller.initialize_framework_caches" do - ActiveSupport.on_load(:action_controller) { self.cache_store ||= Rails.cache if respond_to?(:cache_store) } - end - initializer "action_controller.assets_config", :group => :all do |app| app.config.action_controller.assets_dir ||= app.config.paths["public"].first end + initializer "action_controller.set_helpers_path" do |app| + ActionController::Helpers.helpers_path = app.helpers_paths + end + initializer "action_controller.set_configs" do |app| paths = app.config.paths options = app.config.action_controller + options.logger ||= Rails.logger + options.cache_store ||= Rails.cache + options.javascripts_dir ||= paths["public/javascripts"].first options.stylesheets_dir ||= paths["public/stylesheets"].first options.page_cache_directory ||= paths["public"].first - # make sure readers methods get compiled + # Ensure readers methods get compiled options.asset_path ||= app.config.asset_path options.asset_host ||= app.config.asset_host options.relative_url_root ||= app.config.relative_url_root @@ -37,7 +36,8 @@ module ActionController ActiveSupport.on_load(:action_controller) do include app.routes.mounted_helpers extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) - extend ::ActionController::Railties::Paths.with(app) if respond_to?(:helpers_path) + extend ::ActionController::Railties::Helpers + options.each do |k,v| k = "#{k}=" if respond_to?(k) diff --git a/actionpack/lib/action_controller/railties/helpers.rb b/actionpack/lib/action_controller/railties/helpers.rb new file mode 100644 index 0000000000..3985c6b273 --- /dev/null +++ b/actionpack/lib/action_controller/railties/helpers.rb @@ -0,0 +1,22 @@ +module ActionController + module Railties + module Helpers + def inherited(klass) + super + return unless klass.respond_to?(:helpers_path=) + + if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) } + paths = namespace.railtie_helpers_paths + else + paths = ActionController::Helpers.helpers_path + end + + klass.helpers_path = paths + + if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers + klass.helper :all + end + end + end + end +end diff --git a/actionpack/lib/action_controller/railties/paths.rb b/actionpack/lib/action_controller/railties/paths.rb deleted file mode 100644 index 7e79b036ed..0000000000 --- a/actionpack/lib/action_controller/railties/paths.rb +++ /dev/null @@ -1,24 +0,0 @@ -module ActionController - module Railties - module Paths - def self.with(app) - Module.new do - define_method(:inherited) do |klass| - super(klass) - - if namespace = klass.parents.detect { |m| m.respond_to?(:railtie_helpers_paths) } - paths = namespace.railtie_helpers_paths - else - paths = app.helpers_paths - end - klass.helpers_path = paths - - if klass.superclass == ActionController::Base && ActionController::Base.include_all_helpers - klass.helper :all - end - end - end - end - end - end -end -- cgit v1.2.3 From cfcdd334de1085ee376abc45afe4583a38ff5eed Mon Sep 17 00:00:00 2001 From: Brian Lopez Date: Thu, 15 Mar 2012 14:42:57 -0700 Subject: strip null bytes from Location header as well add tests for stripping \r\n chars since that's already happening --- actionpack/lib/action_controller/metal/redirecting.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/metal/redirecting.rb b/actionpack/lib/action_controller/metal/redirecting.rb index b07742e0e1..3ffb7ef426 100644 --- a/actionpack/lib/action_controller/metal/redirecting.rb +++ b/actionpack/lib/action_controller/metal/redirecting.rb @@ -93,7 +93,7 @@ module ActionController _compute_redirect_to_location options.call else url_for(options) - end.gsub(/[\r\n]/, '') + end.gsub(/[\0\r\n]/, '') end end end -- cgit v1.2.3 From 5ae53d5cde5a5e3041d72a671f7763f6951fab4c Mon Sep 17 00:00:00 2001 From: Sandeep Date: Fri, 16 Mar 2012 19:41:15 +0530 Subject: fixed - warning: instance variable @controller not initialized --- actionpack/lib/action_controller/caching/sweeping.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'actionpack/lib/action_controller') diff --git a/actionpack/lib/action_controller/caching/sweeping.rb b/actionpack/lib/action_controller/caching/sweeping.rb index 808a6fe5f3..bb176ca3f9 100644 --- a/actionpack/lib/action_controller/caching/sweeping.rb +++ b/actionpack/lib/action_controller/caching/sweeping.rb @@ -54,6 +54,11 @@ module ActionController #:nodoc: class Sweeper < ActiveRecord::Observer #:nodoc: attr_accessor :controller + def initialize(*args) + super + @controller = nil + end + def before(controller) self.controller = controller callback(:before) if controller.perform_caching -- cgit v1.2.3