Skip to content
Browse files

Mention that Action Mailer methods are not deferred [ci skip]

Closes #17965, #17968

[Godfrey Chan, Miklós Fazekas]
  • Loading branch information
chancancode committed Dec 13, 2014
1 parent 4a19b3d commit ba58478727581423f060740ec0589159b6743d33
Showing with 35 additions and 0 deletions.
  1. +35 −0 guides/source/
@@ -207,12 +207,47 @@ gem 'rails-deprecated_sanitizer'

### Rails DOM Testing

The [`TagAssertions` module]( (containing methods such as `assert_tag`), [has been deprecated]( in favor of the `assert_select` methods from the `SelectorAssertions` module, which has been extracted into the [rails-dom-testing gem](

### Masked Authenticity Tokens

In order to mitigate SSL attacks, `form_authenticity_token` is now masked so that it varies with each request. Thus, tokens are validated by unmasking and then decrypting. As a result, any strategies for verifying requests from non-rails forms that relied on a static session CSRF token have to take this into account.

### Action Mailer

Previously, calling a mailer method on a mailer class will result in the
corresponding instance method being executed directly. With the introduction of
Active Job and `#deliver_later`, this is no longer true. In Rails 4.2, the
invocation of the instance methods are deferred until either `deliver_now` or
`deliver_later` is called. For example:

class Notifier < ActionMailer::Base
def notify(user, ...)
puts "Called"
mail(to:, ...)
mail = Notifier.notify(user, ...) # Notifier#welcome is not yet called at this point
mail = mail.deliver_now # Prints "Called"

This should not result in any noticible differnces for most applications.
However, if you need some non-mailer methods to be exectuted synchronously, and
you were previously relying on the synchronous proxying behavior, you should
define them as class methods on the mailer class directly:

class Notifier < ActionMailer::Base
def self.broadcast_notifications(users, ...)
users.each { |user| Notifier.notify(user, ...) }

Upgrading from Rails 4.0 to Rails 4.1

1 comment on commit ba58478


This comment has been minimized.

Copy link
Member Author

chancancode commented on ba58478 Dec 13, 2014


The commit message is supposed to read "Mention that Action Mailer methods are now deferred" 🙈

Please sign in to comment.
You can’t perform that action at this time.