Rails3: Undefined Method Includes Values
Thursday, 9 September 2010
I can across an error in Rails3 today when I was trying to implement a scope.
scope :latest, order("created_at asc").first
When trying to run that Scope I’d get
undefined method 'includes_values' for <#Product:rarrarrar>
It had me scratching my head since the trace showed me nothing. So I went through the activerecord codebase, and sure enough it was something stupid that I did.
The scope should return an ActiveRecord object, and not a result set. So simply removing the .first off my scope resulting in a working scope
scope :latest, order("created_at asc")
Its a simple fix, but googling came up with nothing. So I hope this helps someone else who comes across this error.