Farnaz
Farnaz

Reputation: 31

acts_as_taggable_on allowing one tagging per (tagger_id , taggable_id) pair?

I have two models: User and Post

User acts_as_tagger and Post acts_as_taggable

I use the following method to create tagging by a user:

@user.tag(@post , :with =>"a tag" , :on => :tags )

if I call the method two times with two different tags , the second tags gets the place of the first tag and the first is deleted from the taggings table.

In other words acts_as_taggable_on is allowing one row for each pair of (user_id , post_id) to be stored in the taggings table. This does not make sense and I was wondering if I am doing something wrong?

Upvotes: 0

Views: 333

Answers (1)

Farnaz
Farnaz

Reputation: 31

I figured this one out.

tags should be added as a list. If tags are being added gradually by users, then you first need to retrieve the old tag list , append the new tag to it and then call the tag function to retag the post with all available tags.

If you do it one by one , it assumes that the whole tag list is the entered tag , removes all the old ones and stores the new one.

Upvotes: 1

Related Questions