From 98ab4ded376c3d04540bdbdfe6dbbf88c0738701 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 23 Aug 2010 18:31:29 +0200 Subject: Set only helpers_path on inherited hook in action_controller/railtie.rb and use helper(:all) just after that --- actionmailer/lib/action_mailer/railtie.rb | 9 +++++--- actionmailer/lib/action_mailer/railties/paths.rb | 26 ------------------------ 2 files changed, 6 insertions(+), 29 deletions(-) delete mode 100644 actionmailer/lib/action_mailer/railties/paths.rb (limited to 'actionmailer') diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index 3c1f045e79..a2b00addc9 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -1,7 +1,6 @@ require "action_mailer" require "rails" require "abstract_controller/railties/routes_helpers" -require "action_mailer/railties/paths" module ActionMailer class Railtie < Rails::Railtie @@ -12,13 +11,17 @@ module ActionMailer end initializer "action_mailer.set_configs" do |app| + 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 + ActiveSupport.on_load(:action_mailer) do include AbstractController::UrlFor - include app.routes.mounted_helpers(:app) extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) - extend ::ActionMailer::Railties::Paths.with(app) + include app.routes.mounted_helpers(:app) options.each { |k,v| send("#{k}=", v) } end end diff --git a/actionmailer/lib/action_mailer/railties/paths.rb b/actionmailer/lib/action_mailer/railties/paths.rb deleted file mode 100644 index fa9188be77..0000000000 --- a/actionmailer/lib/action_mailer/railties/paths.rb +++ /dev/null @@ -1,26 +0,0 @@ -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