aboutsummaryrefslogtreecommitdiffstats
path: root/actionmailer/lib/action_mailer/railtie.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-01 13:04:53 -0300
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-07-01 13:04:53 -0300
commit4d3eb70aab851dd123ed633052d4956d3f9db459 (patch)
tree799380ef2180e1b757fee221e4b0d09f5c8e6f12 /actionmailer/lib/action_mailer/railtie.rb
parent5de61ccb4ad5136d9f71097ab3b551c3cb8f753e (diff)
parent84ed7b8dfeb2ba47ca8c1b0767c85bbf200e786b (diff)
downloadrails-4d3eb70aab851dd123ed633052d4956d3f9db459.tar.gz
rails-4d3eb70aab851dd123ed633052d4956d3f9db459.tar.bz2
rails-4d3eb70aab851dd123ed633052d4956d3f9db459.zip
Merge pull request #15970 from lengarvey/add_configuration_option_for_mail_preview
Add configuration to enable mail previews
Diffstat (limited to 'actionmailer/lib/action_mailer/railtie.rb')
-rw-r--r--actionmailer/lib/action_mailer/railtie.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/actionmailer/lib/action_mailer/railtie.rb b/actionmailer/lib/action_mailer/railtie.rb
index 671551fa53..409a7a897a 100644
--- a/actionmailer/lib/action_mailer/railtie.rb
+++ b/actionmailer/lib/action_mailer/railtie.rb
@@ -18,8 +18,9 @@ module ActionMailer
options.assets_dir ||= paths["public"].first
options.javascripts_dir ||= paths["public/javascripts"].first
options.stylesheets_dir ||= paths["public/stylesheets"].first
+ options.preview_enabled = Rails.env.development? if options.preview_enabled.nil?
- if Rails.env.development?
+ if options.preview_enabled
options.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
end
@@ -37,6 +38,13 @@ module ActionMailer
register_observers(options.delete(:observers))
options.each { |k,v| send("#{k}=", v) }
+
+ if options.preview_enabled
+ app.routes.append do
+ get '/rails/mailers' => "rails/mailers#index"
+ get '/rails/mailers/*path' => "rails/mailers#preview"
+ end
+ end
end
end