Using ownership .tag() method causes unwanted save on object being tagged. #208

zorn opened this Issue Dec 13, 2011 · 2 comments


None yet
2 participants

zorn commented Dec 13, 2011

So in my current Rails project we're using acts-as-taggable-on.

There are many accounts in the system and each account has many events.

Event is the parent object for a bunch of other things like sessions_descriptions and venues. These things can be tagged and the tags need to be owned by the event so as to not bleed over into another event's tag cloud.

acts-as-taggable-on has support for this. From it's readme some sample code:

class User < ActiveRecord::Base

class Photo < ActiveRecord::Base
acts_as_taggable_on :locations

@some_user.tag(@some_photo, :with => "paris, normandy", :on => :locations)

The problem I'm experiencing is that when I call a method like this it is causing a .save method to be called on @some_photo. This screws me over since I'd pref to keep track of a transient string to manage the human editable tag list and execute the official tagging after_save -- but if doing the official tagging in after_save causes a save I end up with a execution loop and crash Ruby (or throw a more friendly exception on Ruby 1.9.3).

I don't think observers would help me since they sit atop the save callbacks too.

I feel like this is a bug in acts-as-taggable-on (in that using the .tag() method causes a side effect .save to be called on the passed in attributes but I'm hopeful to work around it if I can cause there don't seem to be alot of other tagging modules being actively worked on and I'd pref not to write my own.

Any feedback or suggestions welcome.


artemk commented Jan 7, 2012

@zorn i will add skip_save option, so save will be skipped and you will be able to perform that when you want.

zorn commented Jan 7, 2012

Cool. That's pretty much what I did in my fork.


@artemk artemk added a commit that referenced this issue Jan 7, 2012

@artemk artemk #208 added skip_save for .tag 7d5d82c

artemk closed this Jan 7, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment