37signals/mail_view — pull request #30 by nateberkopec (2012-10-11 22:04:10+00:00)
Title: Suggestions for README examples

We use MailView extensively in our app, but our usage pattern is a little different than suggested by the README, and I thought it might be useful to pass along the way we use MailView.

First - the syntax as written in the current README gives me (in Ruby 1.9.3 and Rails 3.1) a warning on startup:

```
warning: toplevel constant MailPreview referenced by Notifier::MailPreview
```

Taking MailPreview out of an ActionMailer class entirely and putting it in its own file gives you two advantages:

1. No more warnings that make you feel like you're a bad Rubyist and need to go take a shower
2. It makes more sense if you start referring to other mailers (like I do in the README changes I've made)

Also, I've included how we use Structs in our MailViews to act like stub objects. It seems like the easiest way to do it if your mails are simple and not using a lot of attributes from the object, or you don't have existing DB fixtures you can pull from.

I also added Ruby syntax highlighting to the examples, just for some prettiness.