aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/CHANGELOG.md
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2012-07-06 10:39:46 +0100
committerJon Leighton <j@jonathanleighton.com>2012-07-06 10:39:46 +0100
commit07314e64fd62fb8e6165c8c539420160da9437e9 (patch)
tree2c08917ba9db29d9fd6dffd9174019066f51d0c9 /activerecord/CHANGELOG.md
parent8ce61a366474b20368f60eb1c7bf31c3b7297873 (diff)
downloadrails-07314e64fd62fb8e6165c8c539420160da9437e9.tar.gz
rails-07314e64fd62fb8e6165c8c539420160da9437e9.tar.bz2
rails-07314e64fd62fb8e6165c8c539420160da9437e9.zip
Show the records in Relation#inspect
The reason for removing the previous implementation of `#inspect` was that it hid from you that you were dealing with a `Relation` rather than an `Array`. But it is still useful to be able to see the records, particularly if you're writing something like the following in tests: assert_equal [foo], Post.where(:bar) If the assertion fails, you want to see what records were actually loaded. So this implementation makes it clear that you've got a `Relation`, but also shows your records.
Diffstat (limited to 'activerecord/CHANGELOG.md')
-rw-r--r--activerecord/CHANGELOG.md14
1 files changed, 8 insertions, 6 deletions
diff --git a/activerecord/CHANGELOG.md b/activerecord/CHANGELOG.md
index 32261ba9e6..a5c4c36a55 100644
--- a/activerecord/CHANGELOG.md
+++ b/activerecord/CHANGELOG.md
@@ -20,14 +20,16 @@
*Aleksey Magusev*
-* `ActiveRelation#inspect` no longer calls `#to_a`. This means that in places
- where `#inspect` is implied (such as in the console), creating a relation
- will not execute it anymore, you'll have to call `#to_a` when necessary:
+* `ActiveRecord::Relation#inspect` now makes it clear that you are
+ dealing with a `Relation` object rather than an array:.
- User.where(:age => 30) # => returns the relation
- User.where(:age => 30).to_a # => executes the query and returns the loaded objects, as before
+ User.where(:age => 30).inspect
+ # => <ActiveRecord::Relation [#<User ...>, #<User ...>]>
- *Brian Cardarella*
+ User.where(:age => 30).to_a.inspect
+ # => [#<User ...>, #<User ...>]
+
+ *Brian Cardarella & Jon Leighton*
* Add `collation` and `ctype` support to PostgreSQL. These are available for PostgreSQL 8.4 or later.
Example: