diff options
author | Piotr Sarnacki <drogus@gmail.com> | 2010-08-06 16:34:48 +0200 |
---|---|---|
committer | Piotr Sarnacki <drogus@gmail.com> | 2010-09-03 22:59:12 +0200 |
commit | e5af8b7d85abb94f21f4e873c1c267e27be2aad8 (patch) | |
tree | 65e5f8ce3a82dcc6811fc51ad3a052d599ad500c /actionpack/lib/action_controller | |
parent | 8fb9df535e9fcf4c117ffd3254027e0fe2425cb7 (diff) | |
download | rails-e5af8b7d85abb94f21f4e873c1c267e27be2aad8.tar.gz rails-e5af8b7d85abb94f21f4e873c1c267e27be2aad8.tar.bz2 rails-e5af8b7d85abb94f21f4e873c1c267e27be2aad8.zip |
Moved ActionMailer and ActionController railties options to inherited hook
This change is needed, because we must take namespace into account and if
controller's/mailer's class is namespaced, engine's paths should be set
instead of application's ones.
The nice side effect of this is removing unneeded logic in
ActionController::Base.inherited - now the helpers_path should be set
correctly even for engine's controllers, so helper(:all) will always
include correct helpers.
Diffstat (limited to 'actionpack/lib/action_controller')
-rw-r--r-- | actionpack/lib/action_controller/base.rb | 6 | ||||
-rw-r--r-- | actionpack/lib/action_controller/railtie.rb | 14 | ||||
-rw-r--r-- | actionpack/lib/action_controller/railties/paths.rb | 28 |
3 files changed, 32 insertions, 16 deletions
diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 3560ac5b8c..1953e1869f 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -223,11 +223,7 @@ module ActionController def self.inherited(klass) super - if namespace = klass.parents.detect {|m| m.respond_to?(:_railtie) } - klass.helper(all_helpers_from_path(namespace._railtie.config.paths.app.helpers.to_a)) - else - klass.helper :all if klass.superclass == ActionController::Base - end + klass.helper :all if klass.superclass == ActionController::Base end ActiveSupport.run_load_hooks(:action_controller, self) diff --git a/actionpack/lib/action_controller/railtie.rb b/actionpack/lib/action_controller/railtie.rb index 4b5a897b90..2271a51e4e 100644 --- a/actionpack/lib/action_controller/railtie.rb +++ b/actionpack/lib/action_controller/railtie.rb @@ -5,6 +5,7 @@ require "action_view/railtie" require "active_support/deprecation/proxy_wrappers" require "active_support/deprecation" require "abstract_controller/railties/routes_helpers" +require "action_controller/railties/paths" module ActionController class Railtie < Rails::Railtie @@ -41,19 +42,10 @@ module ActionController end initializer "action_controller.set_configs" do |app| - paths = app.config.paths - options = app.config.action_controller - - options.assets_dir ||= paths.public.to_a.first - options.javascripts_dir ||= paths.public.javascripts.to_a.first - options.stylesheets_dir ||= paths.public.stylesheets.to_a.first - options.page_cache_directory ||= paths.public.to_a.first - options.helpers_path ||= paths.app.helpers.to_a - ActiveSupport.on_load(:action_controller) do - extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) include app.routes.mounted_helpers(:app) - options.each { |k,v| send("#{k}=", v) } + extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) + extend ::ActionController::Railties::Paths.with(app) end end diff --git a/actionpack/lib/action_controller/railties/paths.rb b/actionpack/lib/action_controller/railties/paths.rb new file mode 100644 index 0000000000..095beb7a2f --- /dev/null +++ b/actionpack/lib/action_controller/railties/paths.rb @@ -0,0 +1,28 @@ +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) } + app = namespace._railtie + else + app = _app + end + + paths = app.config.paths + options = app.config.action_controller + + options.assets_dir ||= paths.public.to_a.first + options.javascripts_dir ||= paths.public.javascripts.to_a.first + options.stylesheets_dir ||= paths.public.stylesheets.to_a.first + options.page_cache_directory ||= paths.public.to_a.first + options.helpers_path ||= paths.app.helpers.to_a + options.each { |k,v| klass.send("#{k}=", v) } + end + end + end + end + end +end |