diff options
Diffstat (limited to 'actionmailer/lib')
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 9 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railties/paths.rb | 26 |
2 files changed, 29 insertions, 6 deletions
diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index a2b00addc9..3c1f045e79 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -1,6 +1,7 @@ require "action_mailer" require "rails" require "abstract_controller/railties/routes_helpers" +require "action_mailer/railties/paths" module ActionMailer class Railtie < Rails::Railtie @@ -11,17 +12,13 @@ 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 - extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) include app.routes.mounted_helpers(:app) + extend ::AbstractController::Railties::RoutesHelpers.with(app.routes) + extend ::ActionMailer::Railties::Paths.with(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 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 |