There was an error while loading. Please reload this page.
Tower.Mailer
class App.Notifier extends Tower.Mailer @welcome: (user) -> @notification("welcome", name: user.firstName) @notification: (key, locals = {}) -> App.Notifier.defaultUrlOptions.host = locals.host || "mysite.com" subject = Tower.t("emails.#{key}.subject", locals) from = locals.from || I18n.t("emails.from") to = locals.to @mail from: from, to: to, subject: subject
Then you use it like this:
class App.User extends Tower.Model welcome: -> App.Notifier.notification(@).deliver()
Here's a pattern I use a lot
class App.User extends Tower.Model @welcome: (id) -> App.Notifier.notification(@constructor.find(id)).deliver() welcome: -> @enqueue("welcome", @id)