Skip to content

Instantly share code, notes, and snippets.

@nunommc
Forked from lengarvey/staging.rb
Last active November 12, 2015 12:02
Show Gist options
  • Save nunommc/5788d774a9e2ffcd23b5 to your computer and use it in GitHub Desktop.
Save nunommc/5788d774a9e2ffcd23b5 to your computer and use it in GitHub Desktop.
Enabling Rails 4.1 mail previews in staging (or any other env besides development)
# put this in your staging.rb file. Obviously you'll need more config than this it's just an example.
Rails.application.configure do
config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/spec/mailers/previews" : nil
config.action_mailer.show_previews = true
end
# Without the following would display "For security purposes, this information is only available to local requests"
class ::Rails::MailersController
include Rails.application.routes.url_helpers
def local_request?
true
end
end
# assuming you've configured your mail previews in your test folder this will work fine
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment