aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorRobin Dupret <robin.dupret@gmail.com>2014-02-28 20:23:31 +0100
committerRobin Dupret <robin.dupret@gmail.com>2014-02-28 20:23:31 +0100
commita92c707895c5ec7552abd957537605f8bc3d5703 (patch)
treeb342587cb1bcbd3ae45e2d7d5065dc872b32f07e /activerecord/lib
parent3bdc7eb94d5da8c531f5d89a3e4c333f5679e920 (diff)
parent16f96238ba59fd81017b1402eb665e55c5dd4ba5 (diff)
downloadrails-a92c707895c5ec7552abd957537605f8bc3d5703.tar.gz
rails-a92c707895c5ec7552abd957537605f8bc3d5703.tar.bz2
rails-a92c707895c5ec7552abd957537605f8bc3d5703.zip
Merge pull request #14230 from kuldeepaggarwal/doc-select
Correct `select` examples and doc, ref [522c0fd] [ci skip]
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb8
1 files changed, 4 insertions, 4 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 5d38f0dce8..d88858611c 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -202,7 +202,7 @@ module ActiveRecord
# fields are retrieved:
#
# Model.select(:field)
- # # => [#<Model field:value>]
+ # # => [#<Model id: nil, field: "value">]
#
# Although in the above example it looks as though this method returns an
# array, it actually returns a relation object and can have other query
@@ -211,12 +211,12 @@ module ActiveRecord
# The argument to the method can also be an array of fields.
#
# Model.select(:field, :other_field, :and_one_more)
- # # => [#<Model field: "value", other_field: "value", and_one_more: "value">]
+ # # => [#<Model id: nil, field: "value", other_field: "value", and_one_more: "value">]
#
# You can also use one or more strings, which will be used unchanged as SELECT fields.
#
# Model.select('field AS field_one', 'other_field AS field_two')
- # # => [#<Model field: "value", other_field: "value">]
+ # # => [#<Model id: nil, field: "value", other_field: "value">]
#
# If an alias was specified, it will be accessible from the resulting objects:
#
@@ -224,7 +224,7 @@ module ActiveRecord
# # => "value"
#
# Accessing attributes of an object that do not have fields retrieved by a select
- # will throw <tt>ActiveModel::MissingAttributeError</tt>:
+ # except +id+ will throw <tt>ActiveModel::MissingAttributeError</tt>:
#
# Model.select(:field).first.other_field
# # => ActiveModel::MissingAttributeError: missing attribute: other_field