views:

51

answers:

1

I have tried to destroy tags from the given code but it's not working. How can it be accomplished?

 @tag = Tag.find_by_name(params[:name])
  @tag.destroy
  render :update do |page|
    page[:divtag].innerHTML = render :partial => "controls/tag_list"
  end
+1  A: 

The example you provided seems broken. Normally you have a list of tags belonging to a Model (lets say a User model). Then you could call something like this:

# Find a user
@user = User.find_by_name("Bobby")
# Show available tags
@user.tag_list # => ["awesome", "slick", "hefty"] as TagList
# Remove the "slick" tag
@user.tag_list.remove("slick")
# Store change
@user.save

For more information look at the acts-as-taggable-on readme (unfortunately, removing tags is not explained).

Veger
Thanks but i got the ans bu solving it other way, @tag = Tag.find_by_name(params[:name]) @taggings = Tagging.find_all_by_tag_id(@tag.id) for tagging in @taggings tagging.delete end @tag.delete end end
Arpit Vaishnav