Extract assets paths and make them available to Action Mailer as well

This commit is contained in:
David Heinemeier Hansson 2010-06-02 16:49:02 -05:00
parent 942fe6514c
commit 631dc61885
4 changed files with 13 additions and 1 deletions

View File

@ -311,6 +311,7 @@ module ActionMailer #:nodoc:
include AbstractController::Layouts
include AbstractController::Helpers
include AbstractController::Translation
include AbstractController::AssetPaths
helper ActionMailer::MailHelper

View File

@ -13,7 +13,16 @@ module ActionMailer
end
initializer "action_mailer.set_configs" do |app|
paths = app.config.paths
am = app.config.action_mailer
am.assets_dir ||= paths.public.to_a.first
am.javascripts_dir ||= paths.public.javascripts.to_a.first
am.stylesheets_dir ||= paths.public.stylesheets.to_a.first
ActiveSupport.on_load(:action_mailer) do
self.config.merge!(am)
include app.routes.url_helpers
app.config.action_mailer.each do |k,v|

View File

@ -20,5 +20,6 @@ module AbstractController
autoload :Logger
autoload :Rendering
autoload :Translation
autoload :AssetPaths
autoload :ViewPaths
end

View File

@ -13,6 +13,7 @@ module ActionController
MODULES = [
AbstractController::Layouts,
AbstractController::Translation,
AbstractController::AssetPaths,
Helpers,
HideActions,
@ -67,7 +68,7 @@ module ActionController
end
# TODO Move this to the appropriate module
config_accessor :assets_dir, :asset_path, :javascripts_dir, :stylesheets_dir
config_accessor :asset_path
ActiveSupport.run_load_hooks(:action_controller, self)
end