journalduhacker/app/models/tag.rb
2012-09-19 12:25:11 -05:00

17 lines
343 B
Ruby

class Tag < ActiveRecord::Base
attr_accessor :filtered_count
def self.all_with_filtered_counts
counts = TagFilter.count(:group => "tag_id")
Tag.order(:tag).all.map{|t|
t.filtered_count = counts[t.id].to_i
t
}
end
def filtered_count
@filtered_count ||= TagFilter.where(:tag_id => self.id).count
end
end