Reputation: 14514
I want to count how many tags that belongs to konkurrancer. It is a has_many through Tagsmenu relation ship.
I have added the column konkurrancers_count to my Tags table.
Here is my join model:
class Tagsmenu < ActiveRecord::Base
belongs_to :konkurrancer, :counter_cache => :true
belongs_to :tag
end
But when I destroy a konkurrancer the konkurrancers_count column dont get updated.
Upvotes: 0
Views: 130
Reputation: 2572
if you delete
a record it just runs the deletion sql. If you destroy
a record, it will instantiate the model, run all the callbacks, and then run the deletion sql. I think you'll find that you need to use destroy
in order to see the cache column update.
Upvotes: 1