Why is this code according to the documentation works ?
http://api.rubyonrails.org/classes/ActiveRecord/Scoping/Named/ClassMethods.html
class Article < ActiveRecord::Base
scope :featured, where(:featured => true)
def self.titles
map(&:title)
end
end
Article.featured.titles
In my console gets:
NoMethodError: undefined method `map' for #<Class:0xb70bfb0>
My initial answer was the right one: it can’t work…
I guess I finally convinced myself because docs should rule…
Well, I think what’s important in the doc is the idea: you can chain scopes with class methods.
But the implementation of the class method given in example is definitely wrong.