In my code I have:
class User < ActiveRecord::Base
...
scope :matching, -> (column=nil, value=nil) { where("#{column} = ?", value) }
...
end
Assuming a valid public_id: a113f534
(not to be confused with an :id
), when I do:
User.matching("pubid", "a113f534").pluck(:id)
It returns:
[1]
If I do:
User.matching("pubid", "a113f534").pluck(&:id)
It returns:
[[1, "emaildata@inmydb.com", "$blahsomehash", "moreRandomDBdata", nil, Wed, 27 Aug 2014 18:55:33 UTC +00:00, Wed, 27 Aug 2014 21:22:17 UTC +00:00]]
Why does using ampersand-colon (which I know calls to_proc on the symbol) return an array with my id as well as more database column data, as opposed to when I just pass in the symbol, which returns what I want (just the id)?
I was under the impression that for Ruby > ~2.0.0, passing in the ampersand was optional and equivalent to just passing in the symbol.