Displaying 1 result from an estimated 1 matches for "valuecount".
Did you mean:
value_count
2008 Sep 22
1
Ccreating methods on the fly / counting distinct field values
...etty new to ruby and rails, so apologies if this has been covered
before (I couldn''t find a thread on it).
I want to retrieve a count of records held in the DB for every distinct
value of an attribute.
E.g. given a class Address with a postcode field, I would like to retrieve
an array of ValueCount objects. The ValueCount object would hold the value
retrieved from the db and the number of records which hold it.
I''ve written a class specific method which does this:
selects all occurrences of an object with
ActiveRecord.find(:all, :select => "DISTINCT postcode")
then fo...