so I have a very simple model called Movies. I'm trying to add a class method which returns a tidy list of the ratings assigned to movies in the database. It seems I'd want to call Movie.uniq.pluck(:rating)
So I've added the method like so:
class Movie < ActiveRecord::Base
def self.all_ratings
self.uniq.pluck(:rating)
end
end
but it just doesn't work. When it runs I get: undefined method
uniq' for #`... I've tried including ActiveRecord::Calculations but that doesn't seem to help either. I also put a breakpoint in after 'def...' to inspect what methods self had and sure enough, uniq wasn't among them...
I'm clearly doing something wrong, but I just don't quite get what it is.
Anyone have any ideas?
ó_ò