Reading the ActionMailer tutorial, I'm kind of confused by the need to create a named mailer (rails generate mailer UserMailer
). Would I ever want more than one? Why isn't th开发者_C百科ere just a single global one?
Clearly I can just create a single mailer with an arbitrary name and get on with my life, but I'm worried that I'm missing something, ought I to be creating different mailers for different things?
For the same reason you wouldn't want just one controller with 100 actions in it. If you only have one or two small things your site needs to use e-mail for, then one mailer would probably work fine. But if you have multiple e-mail-related components (for example, user registration/password management, newsletter subscriptions, notifications of events on the site, etc.) you may want to break those out into multiple mailers to help keep your code clean and structured.
精彩评论