Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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
vijaydev committed Jan 19, 2012
1 parent 5caf1bd commit e95e932
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -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) }
Expand Down

0 comments on commit e95e932

Please sign in to comment.