Permalink
Browse files

select doesn't take multiple arguments - fixes #4539 [ci skip]

Also, fixed the bit about returning AM::MissingAttributeError. This
seems to be fixed earlier in 3-2-stable only.
  • Loading branch information...
1 parent 5caf1bd commit e95e932fbe38617b72f21fde6cac53f49473d881 @vijaydev vijaydev committed Jan 19, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 activerecord/lib/active_record/relation/query_methods.rb
@@ -75,16 +75,16 @@ def references(*args)
# array, it actually returns a relation object and can have other query
# methods appended to it, such as the other methods in ActiveRecord::QueryMethods.
#
- # This method will also take multiple parameters:
+ # The argument to the method can also be an array of fields.
#
- # >> Model.select(:field, :other_field, :and_one_more)
+ # >> Model.select([:field, :other_field, :and_one_more])
# => [#<Model field: "value", other_field: "value", and_one_more: "value">]
#
- # Any attributes that do not have fields retrieved by a select
- # will return `nil` when the getter method for that attribute is used:
+ # Accessing attributes of an object that do not have fields retrieved by a select
+ # will throw <tt>ActiveModel::MissingAttributeError</tt>:
#
# >> Model.select(:field).first.other_field
- # => nil
+ # => ActiveModel::MissingAttributeError: missing attribute: other_field
def select(value = Proc.new)
if block_given?
to_a.select {|*block_args| value.call(*block_args) }

0 comments on commit e95e932

Please sign in to comment.