rails/rails — pull request #15970 by lengarvey (2014-06-29 14:52:40+00:00)
Title: Add configuration to enable mail previews

Adds `config.mail_preview_enabled`

This allows mail previewing to be enabled easily in non-development
environments such as staging. The default is set to true for development
so no changes should be required to existing Rails applications.

I added this as a new config option in railties since it's required in
both actionmailer and in the railtie finisher. Otherwise we'd be placing
a dependency on `config.action_mailer.preview_path` in order to enable
mail previews.

The mail preview path can still be configured using the existing
`config.action_mailer.preview_path` configuration option.

Adding this prevents devs from having to do stuff like:

```ruby
config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil

routes.append do
get '/rails/mailers' => "rails/mailers#index"
get '/rails/mailers/*path' => "rails/mailers#preview"
end
```

in order to enable mail previewing on staging.