Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configuration to enable mail previews #15970

Conversation

lengarvey
Copy link
Contributor

Adds config.action_mailer.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.

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:

  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.

This config option can be used to enable the mail preview in environments
other than development (such as staging).

Defaults to `true` in staging and false elsewhere.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/staging/development/?

@chancancode chancancode added this to the 4.2.0 milestone Jun 29, 2014
@chancancode
Copy link
Member

@pixeltrix does the overall feature seems fine to you?

@lengarvey
Copy link
Contributor Author

I reworked this so there aren't any more changes inside railties/lib except to remove the route appending from the finisher. This also lets me place the configuration item in config.action_mailer instead of adding a global configuration item.

@rafaelfranca
Copy link
Member

We need to update the configuration guides to add this new config.

@lengarvey
Copy link
Contributor Author

I've updated the configuration guides to include both this new config and the existing config.action_mailer.preview_path config which didn't seem to be covered.

@guilleiguaran
Copy link
Member

Please squash your commits on a single one

Adds `config.action_mailer.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.

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

Adding this avoids devs from having to do stuff like:
https://gist.github.com/lengarvey/fa2c9bd6cdbeba96526a

Update actionmailer/CHANGELOG with new configuration.
Update configuring guide with new configuratation.
Add `config.action_mailer.preview_path` to configuring guide.
@rafaelfranca rafaelfranca merged commit 84ed7b8 into rails:master Jul 1, 2014
rafaelfranca added a commit that referenced this pull request Jul 1, 2014
…_mail_preview

Add configuration to enable mail previews
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants