From e95e932fbe38617b72f21fde6cac53f49473d881 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Thu, 19 Jan 2012 21:41:50 +0530 Subject: [PATCH] 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. --- .../lib/active_record/relation/query_methods.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index b5f202ef6addd..a8ae7208fc9f6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/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]) # => [#] # - # 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 ActiveModel::MissingAttributeError: # # >> 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) }