diff options
Diffstat (limited to 'actionmailer')
-rw-r--r-- | actionmailer/lib/action_mailer/preview.rb | 8 | ||||
-rw-r--r-- | actionmailer/lib/action_mailer/railtie.rb | 12 |
2 files changed, 14 insertions, 6 deletions
diff --git a/actionmailer/lib/action_mailer/preview.rb b/actionmailer/lib/action_mailer/preview.rb index 43d9ec4bb5..ecceaf8c70 100644 --- a/actionmailer/lib/action_mailer/preview.rb +++ b/actionmailer/lib/action_mailer/preview.rb @@ -56,12 +56,18 @@ module ActionMailer protected def load_previews #:nodoc: - Dir["#{preview_path}/**/*_preview.rb"].each{ |file| require_dependency file } + if preview_path? + Dir["#{preview_path}/**/*_preview.rb"].each{ |file| require_dependency file } + end end def preview_path #:nodoc: Base.preview_path end + + def preview_path? #:nodoc: + Base.preview_path? + end end end end diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb index af8009ba97..c893ddfef5 100644 --- a/actionmailer/lib/action_mailer/railtie.rb +++ b/actionmailer/lib/action_mailer/railtie.rb @@ -19,6 +19,10 @@ module ActionMailer options.javascripts_dir ||= paths["public/javascripts"].first options.stylesheets_dir ||= paths["public/stylesheets"].first + if Rails.env.development? + options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil + end + # make sure readers methods get compiled options.asset_host ||= app.config.asset_host options.relative_url_root ||= app.config.relative_url_root @@ -41,11 +45,9 @@ module ActionMailer end end - initializer "action_mailer.configure_mailer_previews", before: :set_autoload_paths do |app| - if Rails.env.development? - options = app.config.action_mailer - options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil - app.config.autoload_paths << options.preview_path + config.after_initialize do + if ActionMailer::Base.preview_path? + ActiveSupport::Dependencies.autoload_paths << ActionMailer::Base.preview_path end end end |