Gives letter_opener an interface for browsing sent emails.
First add the gem to your development environment and run the bundle
command to install it.
gem 'letter_opener_web', '~> 1.0.3', :group => :development
Add to your routes.rb:
Your::Application.routes.draw do
if Rails.env.development?
mount LetterOpenerWeb::Engine, at: "/letter_opener"
end
end
If you are running the app from a Vagrant box, you
might want to skip letter_opener
's launchy
calls and avoid messages like these:
12:33:42 web.1 | Failure in opening /vagrant/tmp/letter_opener/1358825621_ba83a22/rich.html
with options {}: Unable to find a browser command. If this is unexpected, Please rerun with
environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at
https://github.com/copiousfreetime/launchy/issues/new
In that case (or if you just want to browse mails using the web interface), you
can set :letter_opener_web
as your delivery method on your
config/environments/development.rb
:
config.action_mailer.delivery_method = :letter_opener_web
# If not everyone on the team is using vagrant
config.action_mailer.delivery_method = ENV['USER'] == 'vagrant' ? :letter_opener_web : :letter_opener
Usage with rails-footnotes
To prevent rails-footnotes
from outputing debug information to your mails add
the following to your config/initializers/footnotes.rb
:
notes = Footnotes::Filter.notes
Footnotes.setup do |config|
config.before do |controller, filter|
if controller.class.name =~ /LetterOpenerWeb/
filter.notes = []
else
filter.notes = notes
end
end
end
There is a demo app built with tiny-rails available for you to check out how the interface looks like. If you want to give a shot at it:
git clone https://github.com/fgrehm/letter_opener_web
cd letter_opener_web/demo
bundle
unicorn
Special thanks to @alexrothenberg for some ideas on this pull request.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request