aboutsummaryrefslogtreecommitdiffstats
path: root/guides/source/upgrading_ruby_on_rails.md
diff options
context:
space:
mode:
authorGodfrey Chan <godfreykfc@gmail.com>2014-12-12 17:02:18 -0800
committerGodfrey Chan <godfreykfc@gmail.com>2014-12-12 17:02:18 -0800
commitba58478727581423f060740ec0589159b6743d33 (patch)
treeba47f1fc3f557d880dd70c14c2740ad0a8f5f510 /guides/source/upgrading_ruby_on_rails.md
parent4a19b3dea650351aa20d0cad64bf2d5608023a33 (diff)
downloadrails-ba58478727581423f060740ec0589159b6743d33.tar.gz
rails-ba58478727581423f060740ec0589159b6743d33.tar.bz2
rails-ba58478727581423f060740ec0589159b6743d33.zip
Mention that Action Mailer methods are not deferred [ci skip]
Closes #17965, #17968 [Godfrey Chan, Miklós Fazekas]
Diffstat (limited to 'guides/source/upgrading_ruby_on_rails.md')
-rw-r--r--guides/source/upgrading_ruby_on_rails.md35
1 files changed, 35 insertions, 0 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index f26ddd1df8..51f79f44f5 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -207,12 +207,47 @@ gem 'rails-deprecated_sanitizer'
```
### Rails DOM Testing
+
The [`TagAssertions` module](http://api.rubyonrails.org/classes/ActionDispatch/Assertions/TagAssertions.html) (containing methods such as `assert_tag`), [has been deprecated](https://github.com/rails/rails/blob/6061472b8c310158a2a2e8e9a6b81a1aef6b60fe/actionpack/lib/action_dispatch/testing/assertions/dom.rb) in favor of the `assert_select` methods from the `SelectorAssertions` module, which has been extracted into the [rails-dom-testing gem](https://github.com/rails/rails-dom-testing).
### 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:
+
+```ruby
+class Notifier < ActionMailer::Base
+ def notify(user, ...)
+ puts "Called"
+ mail(to: user.email, ...)
+ end
+end
+
+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:
+
+```ruby
+class Notifier < ActionMailer::Base
+ def self.broadcast_notifications(users, ...)
+ users.each { |user| Notifier.notify(user, ...) }
+ end
+end
+```
+
Upgrading from Rails 4.0 to Rails 4.1
-------------------------------------