From e5af8b7d85abb94f21f4e873c1c267e27be2aad8 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Fri, 6 Aug 2010 16:34:48 +0200 Subject: 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. --- actionmailer/lib/action_mailer/railties/paths.rb | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 actionmailer/lib/action_mailer/railties/paths.rb (limited to 'actionmailer/lib/action_mailer/railties/paths.rb') diff --git a/actionmailer/lib/action_mailer/railties/paths.rb b/actionmailer/lib/action_mailer/railties/paths.rb new file mode 100644 index 0000000000..fa9188be77 --- /dev/null +++ b/actionmailer/lib/action_mailer/railties/paths.rb @@ -0,0 +1,26 @@ +module ActionMailer + 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_mailer + + 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.each { |k,v| klass.send("#{k}=", v) } + end + end + end + end + end +end -- cgit v1.2.3