Displaying 1 result from an estimated 1 matches for "distinct_count".
2008 Sep 22
1
Ccreating methods on the fly / counting distinct field values
...for each value issues a
ActiveRecord.count(:all, :conditions => {:postcode => postcode}) call.
I realise this is rather clumsy and could probably be done in a better way,
but it does work.
However, my problem is that I want to write a method to create this sort of
call on the fly.
E.g.
distinct_count :postcode
would create a distinct_count_postcode method which achieves all of the
above for the postcode field. I can then call this in any of my model
classes.
So, can anyone point me in the direction of a tutorial for creating methods
on the fly using symbols?
If anyone can show a better way to...