aboutsummaryrefslogtreecommitdiffstats
path: root/guides
diff options
context:
space:
mode:
authorLauro Caetano <laurocaetano1@gmail.com>2013-12-13 22:11:39 -0200
committerLauro Caetano <laurocaetano1@gmail.com>2013-12-17 13:43:10 -0200
commitd4ee09cda135da9c36a5ddadd2d8c2d35c116be3 (patch)
tree469e6dcb73930059b59e911defaee4a98ca44f43 /guides
parent5d77edf0cf1ed653ed3f7729d77eeb8de219d0b3 (diff)
downloadrails-d4ee09cda135da9c36a5ddadd2d8c2d35c116be3.tar.gz
rails-d4ee09cda135da9c36a5ddadd2d8c2d35c116be3.tar.bz2
rails-d4ee09cda135da9c36a5ddadd2d8c2d35c116be3.zip
Create a blacklist to disallow mutator methods to be delegated to `Array`.
This change was necessary because the whitelist wouldn't work. It would be painful for users trying to update their applications. This blacklist intent to prevent odd bugs and confusion in code that call mutator methods directely on the `Relation`.
Diffstat (limited to 'guides')
-rw-r--r--guides/source/upgrading_ruby_on_rails.md17
1 files changed, 17 insertions, 0 deletions
diff --git a/guides/source/upgrading_ruby_on_rails.md b/guides/source/upgrading_ruby_on_rails.md
index ca5623bf73..60b27aa6e5 100644
--- a/guides/source/upgrading_ruby_on_rails.md
+++ b/guides/source/upgrading_ruby_on_rails.md
@@ -156,6 +156,23 @@ end
ActiveRecord::FixtureSet.context_class.send :include, FixtureFileHelpers
```
+### Mutator methods called on Relation
+
+`Relation` no longer has mutator methods like `#map!` and `#delete_if`. Convert
+to an `Array` by calling `#to_a` before using these methods.
+
+It intends to prevent odd bugs and confusion in code that call mutator
+methods directly on the `Relation`.
+
+```ruby
+# Instead of this
+Author.where(name: 'Hank Moody').compact!
+
+# Now you have to do this
+authors = Author.where(name: 'Hank Moody').to_a
+authors.compact!
+```
+
Upgrading from Rails 3.2 to Rails 4.0
-------------------------------------