Я замечаю очень странное поведение на моем CustomMailer (подкласс ActionMailer):
class CustomMailer < ActionMailer::Base
def deliver(template) # with ":greeting" passed as argument
# WORKS: Renders view app/views/custom_mailer/greeting
CustomMailer.send(template)
# BROKEN: Does not render view app/view/custom_mailer/greeting
self.send(template)
end
def greeting # this gets called by both invocations, but
# only the former renders the view. Why?
...
mail(to: ...
Почему первый рендерит, а не второй?Вот мои гипотезы:
send
нельзя вызвать на self
, не вызывая махинаций - сумасшедшая магия, которая позволяет ActionMailer визуализировать представление (из того, что почтимодель) опирается на методы нацеливания, которые явно вызываются в CustomMailer
- [обновить] что-то о
self
и методах экземпляров по сравнению с CustomMailer и методами класса?