i have a method that works just fine (with rails 3 and PostgreSQL) ; i just wonder if it's possible to make it database-agnostic :
FarmGatePrice.average :price, :group => 'EXTRACT(WEEK FROM date)'
As i understand it, methods to extract a week ISO number from a date are always database-specific.
I could use something like a virtual attribute :week as seen here, but it seems the :group options only accepts raw SQL. I've also seen this solution but it doesn't fit my needs. Another way would be to use a database view, or even to add a :week column filled by a callback method - but i'd prefer not to mess with my schema.
So, any clue ?