Skip to content

Commit 631dc61

Browse files
author
David Heinemeier Hansson
committed
Extract assets paths and make them available to Action Mailer as well
1 parent 942fe65 commit 631dc61

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

actionmailer/lib/action_mailer/base.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,7 @@ class Base < AbstractController::Base
311311
include AbstractController::Layouts
312312
include AbstractController::Helpers
313313
include AbstractController::Translation
314+
include AbstractController::AssetPaths
314315

315316
helper ActionMailer::MailHelper
316317

actionmailer/lib/action_mailer/railtie.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ class Railtie < Rails::Railtie
1313
end
1414

1515
initializer "action_mailer.set_configs" do |app|
16+
paths = app.config.paths
17+
am = app.config.action_mailer
18+
19+
am.assets_dir ||= paths.public.to_a.first
20+
am.javascripts_dir ||= paths.public.javascripts.to_a.first
21+
am.stylesheets_dir ||= paths.public.stylesheets.to_a.first
22+
1623
ActiveSupport.on_load(:action_mailer) do
24+
self.config.merge!(am)
25+
1726
include app.routes.url_helpers
1827

1928
app.config.action_mailer.each do |k,v|

actionpack/lib/abstract_controller.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,6 @@ module AbstractController
2020
autoload :Logger
2121
autoload :Rendering
2222
autoload :Translation
23+
autoload :AssetPaths
2324
autoload :ViewPaths
2425
end

actionpack/lib/action_controller/base.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ def self.without_modules(*modules)
1313
MODULES = [
1414
AbstractController::Layouts,
1515
AbstractController::Translation,
16+
AbstractController::AssetPaths,
1617

1718
Helpers,
1819
HideActions,
@@ -67,7 +68,7 @@ def self.subclasses
6768
end
6869

6970
# TODO Move this to the appropriate module
70-
config_accessor :assets_dir, :asset_path, :javascripts_dir, :stylesheets_dir
71+
config_accessor :asset_path
7172

7273
ActiveSupport.run_load_hooks(:action_controller, self)
7374
end

0 commit comments

Comments
 (0)