Permalink
Browse files

Merge pull request #14230 from kuldeepaggarwal/doc-select

Correct `select` examples and doc, ref [522c0fd] [ci skip]
  • Loading branch information...
2 parents 3bdc7eb + 16f9623 commit a92c707895c5ec7552abd957537605f8bc3d5703 @robin850 robin850 committed Feb 28, 2014
Showing with 4 additions and 4 deletions.
  1. +4 −4 activerecord/lib/active_record/relation/query_methods.rb
@@ -202,7 +202,7 @@ def references!(*table_names) # :nodoc:
# 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,20 +211,20 @@ def references!(*table_names) # :nodoc:
# 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:
#
# Model.select('field AS field_one').first.field_one
# # => "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

0 comments on commit a92c707

Please sign in to comment.