Rails: why do I need more than one ActionMailer?

Reading the ActionMailer tutorial , I am a little confused by the need to create a named mailer ( rails generate mailer UserMailer ). Will I ever be more than one? Why is there not only one global?

It’s clear that I can just create a separate mail program with an arbitrary name and continue my life, but I'm worried that something is missing, should I create different mail programs for different things?

+4
source share
1 answer

For the same reason, you do not need only one controller with 100 actions in it. If you have only one or two little things that your site should use for email, then one postman will probably work fine. But if you have several email-related components (e.g. user registration / password management, newsletter subscriptions, website event notifications, etc.), you might want to split them into several email programs to help Keep your code clean and structured.

+5
source

Source: https://habr.com/ru/post/1340805/


All Articles