Coder Social home page Coder Social logo

mail_view's Introduction

MailView -- Visual email testing

Preview plain text and html mail templates in your browser without redelivering it every time you make a change.

Rails 4.1

NOTE: MailView is part of Rails 4.1+. No need for the plugin anymore!

Install

Add the gem to your Gemfile:

  gem 'mail_view', :git => 'https://github.com/basecamp/mail_view.git'
  # or
  gem "mail_view", "~> 2.0.4"

And run bundle install.

Usage

Since most emails do something interesting with database data, you'll need to write some scenarios to load messages with fake data. Its similar to writing mailer unit tests but you see a visual representation of the output instead.

  # app/mailers/mail_preview.rb or lib/mail_preview.rb
  class MailPreview < MailView
    # Pull data from existing fixtures
    def invitation
      account = Account.first
      inviter, invitee = account.users[0, 2]
      Notifier.invitation(inviter, invitee) 
    end

    # Factory-like pattern
    def welcome
      user = User.create!
      mail = Notifier.welcome(user)
      user.destroy
      mail
    end

    # Stub-like
    def forgot_password
      user = Struct.new(:email, :name).new('[email protected]', 'Jill Smith')
      mail = UserMailer.forgot_password(user)
    end
  end

Methods must return a Mail or TMail object. Using ActionMailer, call Notifier.create_action_name(args) to return a compatible TMail object. Now on ActionMailer 3.x, Notifier.action_name(args) will return a Mail object.

Routing

A mini router middleware is bundled for Rails 2.x support.

  # config/environments/development.rb
  config.middleware.use MailView::Mapper, [MailPreview]

For Rails³ you can map the app inline in your routes config.

  # config/routes.rb
  if Rails.env.development?
    mount MailPreview => 'mail_view'
  end

Now just load up http://localhost:3000/mail_view.

Interface

Plain text view HTML view

mail_view's People

Contributors

aitor avatar benjaminoakes avatar clairemcginty avatar grosser avatar iainbeeston avatar jeremy avatar jonleighton avatar josh avatar joshnabbott avatar julien-duponchelle avatar kirkland avatar linojon avatar nateberkopec avatar packagethief avatar roryfranklin avatar sc0ttman avatar slavingia avatar stereoscott avatar toolmantim avatar vijaydev avatar wesgibbs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mail_view's Issues

error installing mail view 2.0.2

For some reason jeremy is referenced in the install path:

$ gem install mail_view
ERROR:  While executing gem ... (Gem::Package::PathError)
    installing into parent path /Users/jeremy/work/plugins/mail_view/Gemfile 
    of /Users/nathany/.gem/ruby/2.0.0/gems/mail_view-2.0.2 is not allowed

I currently have mail_view 2.0.1 installed.

Add License information to Gemspec

This will make it show up on rubygems.org. I'm doing due diligence on our gems and need to find out the licenses for all the gems. Having it show up on rubygems.org cuts out the step of having to go to the github repo.

uninitialized constant MailPreview

/Users/r625503/Programming/projectv/config/routes.rb:4:in `block in <top (required)>': uninitialized constant MailPreview (NameError)
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:285:in `instance_exec'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:285:in `eval_block'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/actionpack-3.2.16/lib/action_dispatch/routing/route_set.rb:263:in `draw'
    from /Users/r625503/Programming/projectv/config/routes.rb:1:in `<top (required)>'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/bundler/gems/rails-dev-boost-3e25b06c5c53/lib/rails_development_boost/loadable_patch.rb:14:in `load'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `block in load_paths'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `each'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:40:in `load_paths'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:16:in `reload!'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:26:in `block in updater'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.16/lib/active_support/file_update_checker.rb:78:in `call'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/activesupport-3.2.16/lib/active_support/file_update_checker.rb:78:in `execute'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:27:in `updater'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/routes_reloader.rb:7:in `execute_if_updated'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application/finisher.rb:66:in `block in <module:Finisher>'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/initializable.rb:30:in `run'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `each'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/application.rb:136:in `initialize!'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/r625503/Programming/projectv/config/environment.rb:5:in `<top (required)>'
    from /Users/r625503/Programming/projectv/config.ru:3:in `block in <main>'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/r625503/Programming/projectv/config.ru:in `new'
    from /Users/r625503/Programming/projectv/config.ru:in `<main>'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/commands/server.rb:46:in `app'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/commands/server.rb:70:in `start'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/commands.rb:50:in `tap'
    from /Users/r625503/.rvm/gems/ruby-2.0.0-p195/gems/railties-3.2.16/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Not sure why though. The gems in the gemfile and I copy-pasted the mounting call into routes.

ruby is at 2.0.0 and rails is at 3.2.16

Default format

Just a quick question, what's the best way to get HTML be the default view when clicking in to an email?

How to get it to reload changed mail tempates?

I remember this being a problem in the past, but I thought it was fixed with an update to this gem.

When I update my notifier templates and refresh the

http://localhost:3001/mail_view/signup 

Page, it doesn't show the updated version. Any suggestions how to debug this, or what might be going wrong? :cache_classes is set to false, and the rest of my app auto-reloads properly. Rails 3.2.16

I have to restart my environment to make mail_preview loading changes

Steps to reproduce:

  1. Executing this code which has an error
class MailPreview < MailView
    def invitation
      this_will_raise_an_error!!

      account = Account.first
      inviter, invitee = account.users[0, 2]
      Notifier.invitation(inviter, invitee) 
    end
end
  1. Then removing the
this_will_raise_an_error!!

The error persists until I restart the server

How should it behave?

I shouldn't need to restart the server in order to make the MailPreview execute without the "this_will_raise_an_error!!" line

Catch all route prevents previewing in Rails 4.1

Hi,

I'm using Rails 4.1 and have not installed the gem separately.
I have a catch all route as the last route in my routes.rb file

get '*path' => 'main#page_not_found'

This catches also the preview path.

What would be the recommended way to implement the catch all route so that it would not conflict with the preview path? Or can I explicitly define the preview path in the route file?

Publish as a gem

Well, you know, no one wants a new commit to break your application... Using this repo as source in a project Gemfile is just bad practice.

Helper methods gone in normal actions

When doing e.g.

class UserMailer < ActionMailer::Base
  include ApplicationHelper
  class Preview < MailView
    ...
  end
end

All helper actions are no longer available in normal app actions,
please warn users about this issue or do not suggest to put the new class inside an existing mailer

Fallback font for non-Mac users

Please can you add a fallback font (even if it's just 'sans-serif') to #message_headers? It looks pretty ugly when it falls back to Times New Roman!

Thanks

A copy of MailPreview has been removed from the module tree but is still active!

Using Rails 4.0.0.beta1 and Ruby 2.0.0. While using mail_view, if I encounter an error, fix the error and reload, I get the error in $subject. Restarting webrick resolves the issue.

Full backtrace:

activesupport (4.0.0.beta1) lib/active_support/dependencies.rb:445:in `load_missing_constant'
activesupport (4.0.0.beta1) lib/active_support/dependencies.rb:183:in `const_missing'
app/mailers/mail_preview.rb:3:in `week_parent_report'
/home/brianb/.rvm/gems/ruby-2.0.0-p0/bundler/gems/mail_view-2e2b00897cb7/lib/mail_view.rb:38:in `call'
/home/brianb/.rvm/gems/ruby-2.0.0-p0/bundler/gems/mail_view-2e2b00897cb7/lib/mail_view.rb:19:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/journey/router.rb:69:in `block in call'
actionpack (4.0.0.beta1) lib/action_dispatch/journey/router.rb:57:in `each'
actionpack (4.0.0.beta1) lib/action_dispatch/journey/router.rb:57:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/routing/route_set.rb:651:in `call'
rack (1.5.2) lib/rack/etag.rb:23:in `call'
rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
rack (1.5.2) lib/rack/head.rb:11:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/flash.rb:241:in `call'
rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/cookies.rb:452:in `call'
dragonfly (0.9.14) lib/dragonfly/cookie_monster.rb:9:in `call'
activerecord (4.0.0.beta1) lib/active_record/query_cache.rb:36:in `call'
activerecord (4.0.0.beta1) lib/active_record/connection_adapters/abstract/connection_pool.rb:632:in `call'
activerecord (4.0.0.beta1) lib/active_record/migration.rb:348:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (4.0.0.beta1) lib/active_support/callbacks.rb:373:in `_run__3326616950422825945__call__callbacks'
activesupport (4.0.0.beta1) lib/active_support/callbacks.rb:78:in `run_callbacks'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/reloader.rb:64:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:38:in `call_app'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:21:in `block in call'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:67:in `block in tagged'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:25:in `tagged'
activesupport (4.0.0.beta1) lib/active_support/tagged_logging.rb:67:in `tagged'
railties (4.0.0.beta1) lib/rails/rack/logger.rb:21:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
rack (1.5.2) lib/rack/runtime.rb:17:in `call'
activesupport (4.0.0.beta1) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
actionpack (4.0.0.beta1) lib/action_dispatch/middleware/static.rb:64:in `call'
dragonfly (0.9.14) lib/dragonfly/middleware.rb:13:in `call'
rack-cache (1.2) lib/rack/cache/context.rb:136:in `forward'
rack-cache (1.2) lib/rack/cache/context.rb:245:in `fetch'
rack-cache (1.2) lib/rack/cache/context.rb:185:in `lookup'
rack-cache (1.2) lib/rack/cache/context.rb:66:in `call!'
rack-cache (1.2) lib/rack/cache/context.rb:51:in `call'
railties (4.0.0.beta1) lib/rails/engine.rb:510:in `call'
railties (4.0.0.beta1) lib/rails/application.rb:96:in `call'
rack (1.5.2) lib/rack/lock.rb:17:in `call'
rack (1.5.2) lib/rack/content_length.rb:14:in `call'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in `service'
/home/brianb/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:138:in `service'
/home/brianb/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/httpserver.rb:94:in `run'
/home/brianb/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/webrick/server.rb:295:in `block in start_thread'
# Gemfile.lock
GIT
  remote: git://github.com/37signals/mail_view.git
  revision: 2e2b00897cb79b1a6924240b43a7521915efe215
  specs:
    mail_view (1.0.1)
      tilt

GIT
  remote: git://github.com/vmg/rinku.git
  revision: 49cf3588bb7ce9d4626e67b70a5f8cb90308b7c2
  specs:
    rinku (1.7.2)

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (4.0.0.beta1)
      actionpack (= 4.0.0.beta1)
      mail (~> 2.5.3)
    actionpack (4.0.0.beta1)
      activesupport (= 4.0.0.beta1)
      builder (~> 3.1.0)
      erubis (~> 2.7.0)
      rack (~> 1.5.2)
      rack-test (~> 0.6.2)
    activemodel (4.0.0.beta1)
      activesupport (= 4.0.0.beta1)
      builder (~> 3.1.0)
    activerecord (4.0.0.beta1)
      activemodel (= 4.0.0.beta1)
      activerecord-deprecated_finders (~> 0.0.3)
      activesupport (= 4.0.0.beta1)
      arel (~> 4.0.0.beta1)
    activerecord-deprecated_finders (0.0.3)
    activesupport (4.0.0.beta1)
      i18n (~> 0.6.2)
      minitest (~> 4.2)
      multi_json (~> 1.3)
      thread_safe (~> 0.1)
      tzinfo (~> 0.3.33)
    arel (4.0.0.beta2)
    atomic (1.0.1)
    builder (3.1.4)
    coffee-rails (4.0.0.beta1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0.beta, < 5.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.6.2)
    columnize (0.3.6)
    commonjs (0.2.6)
    debugger (1.5.0)
      columnize (>= 0.3.1)
      debugger-linecache (~> 1.2.0)
      debugger-ruby_core_source (~> 1.2.0)
    debugger-linecache (1.2.0)
    debugger-ruby_core_source (1.2.0)
    dragonfly (0.9.14)
      multi_json (~> 1.0)
      rack
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    hike (1.2.1)
    i18n (0.6.4)
    jbuilder (1.0.2)
      activesupport (>= 3.0.0)
    jquery-rails (2.2.1)
      railties (>= 3.0, < 5.0)
      thor (>= 0.14, < 2.0)
    json (1.7.7)
    less (2.3.1)
      commonjs (~> 0.2.6)
    less-rails (2.3.2)
      actionpack (>= 3.1)
      less (~> 2.3.1)
    libv8 (3.11.8.17)
    mail (2.5.3)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.21)
    minitest (4.7.0)
    multi_json (1.7.2)
    polyglot (0.3.3)
    rack (1.5.2)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-test (0.6.2)
      rack (>= 1.0)
    rails (4.0.0.beta1)
      actionmailer (= 4.0.0.beta1)
      actionpack (= 4.0.0.beta1)
      activerecord (= 4.0.0.beta1)
      activesupport (= 4.0.0.beta1)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.0.0.beta1)
      sprockets-rails (~> 2.0.0.rc3)
    railties (4.0.0.beta1)
      actionpack (= 4.0.0.beta1)
      activesupport (= 4.0.0.beta1)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.17.0, < 2.0)
    rake (10.0.4)
    rdoc (3.12.2)
      json (~> 1.4)
    ref (1.0.4)
    sass (3.2.7)
    sass-rails (4.0.0.beta1)
      railties (>= 4.0.0.beta, < 5.0)
      sass (>= 3.1.10)
      sprockets-rails (~> 2.0.0.rc0)
      tilt (~> 1.3)
    sprockets (2.9.0)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.0.0.rc3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (~> 2.8)
    sqlite3 (1.3.7)
    therubyracer (0.11.4)
      libv8 (~> 3.11.8.12)
      ref
    thor (0.18.0)
    thread_safe (0.1.0)
      atomic
    tilt (1.3.6)
    treetop (1.4.12)
      polyglot
      polyglot (>= 0.3.1)
    twitter-bootstrap-rails (2.2.6)
      actionpack (>= 3.1)
      execjs
      railties (>= 3.1)
    tzinfo (0.3.37)
    uglifier (1.3.0)
      execjs (>= 0.3.0)
      multi_json (~> 1.0, >= 1.0.2)

PLATFORMS
  ruby

DEPENDENCIES
  coffee-rails (~> 4.0.0.beta1)
  debugger
  dragonfly
  jbuilder (~> 1.0.1)
  jquery-rails
  less-rails
  mail_view!
  rack-cache
  rails (= 4.0.0.beta1)
  rinku!
  sass-rails (~> 4.0.0.beta1)
  sqlite3
  therubyracer
  twitter-bootstrap-rails
  uglifier (>= 1.0.3)

Doesn't update without server restart

When I'm in :development, most of my classes update in the runtime as I edit their code. But when I edit my Preview class, say to add a new preview method, nothing changes in the browser.

The Iframe's height.

Hi!

First off, I'm using the rails 4.1 Mailer Preview functionality, and it's working well.

However, the 800 px height on the iframe is REALLY killing me. I've been looking for a way to extend it, and I just can't seem to find a way. Do you happen to know how I could change it?

Adopt more "the Rails way"-like usage

The README suggests that MailView is something similar to the unit tests for emails but with visual output. Then it goes on to suggest we should embed preview generation code directly into our code clases. While the suggested organization makes it easier to get started, it's not something seen very often in the Rails land (thinking specifically about test/spec code here).

I suggest to adopt usage more along the lines of the Rails way, ie. code organization more similar to that of tests and specs.

In my local integration, I organized preview code in following manner:

app/
  mailers/
    notification_mailer.rb ← defines NotificationMailer < ActionMailer::Base
mail_views/
  notification_mailer_preview.rb ← defines NotificationMailerPreview < MailView

Here we have application-level dir "mail_views" (in line of specs/tests) in which there is an .rb file for every mailer (eg. notifier_mailer_preview.rb) with a definition of MailerPreview class (eg. NotifierMailerPreview < MailVew). It then contains one or more method for every method in the original Mailer class.

If any organization is standardized it would be easy to automatically generate routes, but that's a topic for another issue.

Changes to I18n.locale are not retained in the email_template

We overrode the default_email_template to customize the layout of the mail view. Part of that customization is making the field descriptions translatable. For some reason, I18n.locale is always 'en' in that template even if it is explicitly set in the MailView action.

Is there somewhere else the locale needs to be set?

README.md: images are broken

Last lines of the README.md file contain broken links to images that were stored on imageshack, but they are removed since.

Anyone has these images somewhere?

Email preview in production in rails 4

Hello,

I am using rails 4.1.1 and ActionMailer::Preview. In development environment everything is working excellent.

But in production environment the preview routes are not accessible. I store the previews in test/mailers/previews/
Is is possible to enable them for production?

Thanks!

Rolling Back Database Changes

I don't like to depend on certain data being available in my development database when previewing mail. So I add the data the preview operates on when running the preview. But this means my development database is getting a constant stream of data every time I view my e-mail. I added the following to my class to wrap everything in a transaction and rollback at the end. But was wondering if there is a more obvious way that I missed?

def call env
  ret = nil
  begin
    ActiveRecord::Base.transaction do
      ret = super
      raise ActiveRecord::Rollback
    end
  rescue ActiveRecord::Rollback
  end
  ret
end

broken utf8 chars

our mails look find in any mailer, but in mail_view they got "für" instead of "für"

change the gemspec

I needed to add the following line to the mail_view.gemspec in order to install it locally

s.files += Dir["#{File.dirname(FILE)}/lib/mail_view/*"]

Otherwise the files in de lib/mail_view aren't included in the gem

Preview Real Mail

What if this came with its own mail delivery method? Then this could also be used to preview the real mail as it would be sent out.

# config/environments/development.rb
config.action_mailer.delivery_method = :mail_view

The deliveries would need to persist somewhere, maybe just inside the tmp directory. Then when an email is sent out the URL can be logged for easy preview, maybe even an option to open it with Launchy so it automatically pops up when delivering.

mail_view stopped working with 2.0.3

Starting 2.0.3, I'm seeing the following error by accessing /mail_view. Thoughts?

Errno::ENOENT - No such file or directory - /Users/kenn/.rvm/gems/ruby-2.0.0-p247/gems/mail_view-2.0.3/lib/mail_view/index.html.erb:
  tilt (1.4.1) lib/tilt/template.rb:91:in `read_template_file'
  tilt (1.4.1) lib/tilt/template.rb:68:in `block in initialize'
  tilt (1.4.1) lib/tilt/template.rb:69:in `initialize'
  tilt (1.4.1) lib/tilt.rb:61:in `new'
  mail_view (2.0.3) lib/mail_view.rb:80:in `index_template'
  mail_view (2.0.3) lib/mail_view.rb:32:in `call'
  mail_view (2.0.3) lib/mail_view.rb:20:in `call'
  actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in `block in call'
  actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in `call'
  actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680:in `call'
  newrelic_rpm (3.7.0.177) lib/new_relic/rack/error_collector.rb:50:in `call'
  newrelic_rpm (3.7.0.177) lib/new_relic/rack/agent_hooks.rb:28:in `call'
  newrelic_rpm (3.7.0.177) lib/new_relic/rack/browser_monitoring.rb:23:in `call'
  newrelic_rpm (3.7.0.177) lib/new_relic/rack/developer_mode.rb:42:in `call'
  request_store (1.0.5) lib/request_store/middleware.rb:9:in `call'
  rack (1.5.2) lib/rack/etag.rb:23:in `call'
  rack (1.5.2) lib/rack/conditionalget.rb:25:in `call'
  rack (1.5.2) lib/rack/head.rb:11:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241:in `call'
  rack (1.5.2) lib/rack/session/abstract/id.rb:225:in `context'
  rack (1.5.2) lib/rack/session/abstract/id.rb:220:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/cookies.rb:486:in `call'
  activerecord (4.0.2) lib/active_record/query_cache.rb:36:in `call'
  activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:in `call'
  activerecord (4.0.2) lib/active_record/migration.rb:369:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.0.2) lib/active_support/callbacks.rb:373:in `_run__867493693933363244__call__callbacks'
  activesupport (4.0.2) lib/active_support/callbacks.rb:80:in `run_callbacks'
  actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in `call'
  airbrake (3.1.14) lib/airbrake/rails/middleware.rb:13:in `call'
  better_errors (1.0.1) lib/better_errors/middleware.rb:84:in `protected_app_call'
  better_errors (1.0.1) lib/better_errors/middleware.rb:79:in `better_errors_call'
  better_errors (1.0.1) lib/better_errors/middleware.rb:56:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.0.2) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `block in tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in `tagged'
  activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:in `tagged'
  railties (4.0.2) lib/rails/rack/logger.rb:20:in `call'
  quiet_assets (1.0.2) lib/quiet_assets.rb:18:in `call_with_quiet_assets'
  actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in `call'
  rack (1.5.2) lib/rack/lock.rb:17:in `call'
  actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  airbrake (3.1.14) lib/airbrake/user_informer.rb:16:in `_call'
  airbrake (3.1.14) lib/airbrake/user_informer.rb:12:in `call'
  railties (4.0.2) lib/rails/engine.rb:511:in `call'
  railties (4.0.2) lib/rails/application.rb:97:in `call'
  rack (1.5.2) lib/rack/content_length.rb:14:in `call'
  thin (1.6.1) lib/thin/connection.rb:82:in `block in pre_process'
  thin (1.6.1) lib/thin/connection.rb:80:in `pre_process'
  thin (1.6.1) lib/thin/connection.rb:55:in `process'
  thin (1.6.1) lib/thin/connection.rb:41:in `receive_data'
  eventmachine (1.0.3) lib/eventmachine.rb:187:in `run'
  thin (1.6.1) lib/thin/backends/base.rb:73:in `start'
  thin (1.6.1) lib/thin/server.rb:162:in `start'
  rack (1.5.2) lib/rack/handler/thin.rb:16:in `run'
  rack (1.5.2) lib/rack/server.rb:264:in `start'
  railties (4.0.2) lib/rails/commands/server.rb:84:in `start'
  zeus (0.13.3) lib/zeus/rails.rb:158:in `server'
  zeus (0.13.3) lib/zeus.rb:116:in `block in command'
  zeus (0.13.3) lib/zeus.rb:103:in `command'
  zeus (0.13.3) lib/zeus.rb:80:in `block (3 levels) in go'
  zeus (0.13.3) lib/zeus.rb:80:in `block (2 levels) in go'
  zeus (0.13.3) lib/zeus.rb:73:in `block in go'
  zeus (0.13.3) lib/zeus.rb:62:in `go'
  zeus (0.13.3) lib/zeus.rb:78:in `block (3 levels) in go'
  zeus (0.13.3) lib/zeus.rb:78:in `block (2 levels) in go'
  zeus (0.13.3) lib/zeus.rb:73:in `block in go'
  zeus (0.13.3) lib/zeus.rb:62:in `go'
  zeus (0.13.3) lib/zeus.rb:78:in `block (3 levels) in go'
  zeus (0.13.3) lib/zeus.rb:78:in `block (2 levels) in go'
  zeus (0.13.3) lib/zeus.rb:73:in `block in go'
  zeus (0.13.3) lib/zeus.rb:62:in `go'
  -e:1:in `<main>'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.