Browse files

Add callbacks documentation for upgrading to 4.1.

It is now expected in 4.1 to use an explicit block rather than implicit
when setting callbacks through ActiveSupport::Callbacks. This commit
highlights this new expectation as part of the upgrading documentation.
  • Loading branch information...
1 parent 0e7744e commit 489e531334bc448c88f9b5a74f1bbbcaeb3f067b @nickpellant nickpellant committed Jul 7, 2014
Showing with 14 additions and 0 deletions.
  1. +14 −0 guides/source/upgrading_ruby_on_rails.md
View
14 guides/source/upgrading_ruby_on_rails.md
@@ -432,6 +432,20 @@ symbol access is no longer supported. This is also the case for
`store_accessors` based on top of `json` or `hstore` columns. Make sure to use
string keys consistently.
+### Explicit block use for `ActiveSupport::Callbacks`
+
+Rails 4.1 now expects an explicit block to be passed when calling
+`ActiveSupport::Callbacks.set_callback`. This change stems from
+`ActiveSupport::Callbacks` being largely rewritten for the 4.1 release.
+
+```ruby
+# Rails 4.1
+set_callback :save, :around, ->(r, block) { stuff; result = block.call; stuff }
+
+# Rails 4.0
+set_callback :save, :around, ->(r, &block) { stuff; result = block.call; stuff }
+```
+
Upgrading from Rails 3.2 to Rails 4.0
-------------------------------------

0 comments on commit 489e531

Please sign in to comment.