Перевод "Rails in a nutshell Chapter 5. Action Mailer" |
- Statistics
- Participants
- Translate into Russian
- Translation result
- 16% translated in draft.
If you do not want to register an account, you can sign in with OpenID.
Rails in a nutshell Chapter 5. Action Mailer | ||
Chapter 5. Action Mailer | ||
Action Mailer is a framework for sending and receiving email. It makes sending templated email, gracefully degrading HTML email, email with attachments, and receiving email simple, while abstracting away complex issues like MIME encoding and quoting. This chapter will cover all the most important aspects of Action Mailer including the generation of mailers, sending email, and the configuration and testing of mailers. | Action Malier - это каркас для отправки и получения почты. Он позволяет отправлять шаблонные почтовые сообщения, существенно облегчает работу с HTML-сообщениями и почтовыми вложениями, упрощает получение почты, абстрагируясь от таких сложных понятий, как MIME-кодирование и цитирование. В этой главе рассматриваются наиболее важные аспекты из Action Mailer, включая генерацию отправителей, отправку почты, а также настройку и тестирование отправителей. | |
Generating Mailers | ||
Rails provides a generator for creating new mailer models. The generator is passed the mailer name in underscored or camel case format followed by zero or more actions: | Rails предоставляет генератор для создания новой модели отправителя. Генератор получает имя отправителя с нижними подчеркиваниями или CamelCase-формате, после которого могут быть перечислены действия: | |
script/generate mailer mailer_name [action...] | ||
The generator creates the following files: | ||
* | ||
mailer class in app/models. | ||
* | ||
view templates for each action in app/views/mailer_name. | шаблоны видов для каждого действия в app/views/mailer_name. | |
* | ||
unit test stub in test/unit. | ||
* | ||
test fixtures for each action in test/fixtures/mailer_name. | тестовые заготовки для каждого действия в test/fixtures/mail_name. | |
The following command generates a new mailer model class named OrderMailer with a single action confirmation: | Следующая команда сгенерирует новый класс модели отправителя с именем OrderMailer с единственным действием confirmation: | |
$ script/generate mailer OrderMailer confirmation | ||
create app/models/ | ||
create app/views/order_mailer | ||
create test/unit/ | ||
create test/fixtures/order_mailer | ||
create app/models/order_mailer.rb | ||
create test/unit/order_mailer_test.rb | ||
create app/views/order_mailer/confirmation.erb | ||
create test/fixtures/order_mailer/confirmation | ||
Sending Email | ||
A mailer model's job is to encapsulate the creation and delivery of the different email messages that you need for a particular component of your application. For example, an OrderMailer would define all of the email messages for communicating with a customer regarding an order they've placed at your online store. | Задача модели отправителя заключается в инкапсулировании создания и доставки различных почтовых сообщений, обычно используемых в приложениях. Например, OrderMailer определяет все виды почтовых сообщений для связи с клиентами через заказы, которые они оставляют в нашем online-хранилище. | |
There are two parts to a mailer: the model and the view. The model portion is stored along with the rest of your models in app/models. The mailer's views are stored in a subdirectory, named after the mailer model, underneath app/views with the rest of your application's views. Therefore an OrderMailer model would itself be stored as app/models/order_mailer.rb and would look for its view templates under the directory app/views/order_mailer. | Есть две части отправителя: модель (model) и представление (view). Модель хранится вместе с вашими остальными моделями в каталоге app/models. Представления отправителя сохраняются в подкаталоге, именованном по названию модели отправителя, в подапке app/views вместе с остальными представлениями приложения. Следовательно, модель с названием OrderMailer, должна сохранится как app/models/order_mailer.rb и искать шаблоны представлений в каталоге app/views/order_mailer/. |

— mailer - отправитель, рассылка? — and_rew