aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation.rb
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/lib/active_record/relation.rb
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/lib/active_record/relation.rb')
-rw-r--r--activerecord/lib/active_record/relation.rb4
1 files changed, 4 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation.rb b/activerecord/lib/active_record/relation.rb
index e268d451e0..7725331694 100644
--- a/activerecord/lib/active_record/relation.rb
+++ b/activerecord/lib/active_record/relation.rb
@@ -514,6 +514,10 @@ module ActiveRecord
@values.dup
end
+ def inspect
+ "#<#{self.class.name} #{to_a.inspect}>"
+ end
+
private
def references_eager_loaded_tables?