mbleigh / acts-as-taggable-on

A tagging plugin for Rails applications that allows for custom tagging along dynamic contexts.
http://mbleigh.lighthouseapp.com/projects/10116-acts-as-taggable-on
MIT License
4.96k stars 1.19k forks source link

acts_as_taggable changes in after_commit callback? #475

Open concept47 opened 10 years ago

concept47 commented 10 years ago

Is there a way to get a hold of changes from acts_as_taggable in the after_commit callback? Rails provides the previous_changes Hash for ActiveRecord object and was just wondering if acts-as-taggable had anything like it (I know of the _list_changed? method on acts_as taggable objects)

seuros commented 10 years ago

I'm not totally sure, but if you use cache, the cache column will be changed.

pioz commented 5 years ago

It would be nice if previous_chages[:tag_list] also worked without column cache. Now the value of previous_changes[:tag_list] seems to work in half way: the first element is always nil while the second element of the array is correct.

stanhu commented 5 years ago

@pioz That issue may be a limitation of Rails 5+:

brentgreeff commented 5 years ago

I am using this gem with RailsAdmin, - I have got partial caching for my Taggable model, - if I save taggable, everything is great, when I assign to tag_list Taggable is saved and the cache is invalidated. BUT when the tag model is changed in RailsAdmin the cache is not invalidated.

How can I run code when a Tag is saved?

I tried to monkey patch ActsAsTaggableOn::Tag with a callback but it doesnt work.

I am starting to think that I need to remove RailsAdmin or at least write my own admin for saving tags, or I need to write a sweeper to check which tags have been changed in the past hour.