Method: Tag.counts
- Defined in:
- app/models/tag.rb
.counts(options = {}) ⇒ Object
Returns an array of tags with a count attribute
12 13 14 15 16 17 18 19 20 |
# File 'app/models/tag.rb', line 12 def self.counts(={}) with_scope(:find => { :select => "tags.id, tags.name, count(*) as count", :joins => :taggings, :group => "tags.id, tags.name", :order => "count desc, tags.name" }) do all() end end |