acts_as_taggable_on gem have issue with after_save callback

Today I had spent a lot of time fixing an after_save callback issue related with acts_as_taggable_on gem. We're associating keyword tag to a model using the following command:

acts_as_taggable_on :keywords

And we've a after_save call back in that model which uses the updated keywords. But the issue was in the callback, if you reload the object you will lose the new keywords associated with it, because the keywords are not yet saved.

Then I Googled about this issue and found the following blog which helped me to solve the issue: http://blog.romanandreg.com/post/176944361/activerecord-callbacks-acts-as-taggable-gotcha I tried with the update_tags mentioned in the blog, but with the latest acts_as_taggable_on gem this fix is not working. Then I gone through the code of acts_as_taggable_on gem, and in core.rb I found the following line:

after_save :save_tags

Then I tried calling save_tags from my callback method. Thats it! It got fixed!!

blog comments powered by Disqus
Write a named scope to fetc... →
← Updated time_diff gem