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
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With