How do I make a counter cachce column for tags (Count how many konkurrancer that belongs to a tag) And how do I make a task that update the counters on delete and when creating a new konkurrancer. And a task to update all counters. Instead of typing them manually first.
class Konkurrancer < ActiveRecord::Base
has_many :tagsmenus, :dependent => :destroy
has_many :tags, :through => :tagsmenus
end
My model:
class Tagsmenu < ActiveRecord::Base
belongs_to :konkurrancer
end
class Tag < ActiveRecord::Base
has_many :tagsmenus
has_many :konkurrancers, :through => :tagsmenus
end
This is (was, I haven’t checked 3.1) not builtin.
But see a really nice blog post here, you’ll be able to implement it directly following the advice there.