Last updated by
2 years ago
Page: Taggable Plugin, Version:9
Taggable Plugin
There is more up-to-date information about this plugin at http://www.grails.org/plugin/taggableThis plugin provides an alternative to the Acts as Taggable hosted at grails.org and with the following features.
- Classes can be made taggable by implementing the
org.grails.taggable.Taggableinterface - Method chaining can be used to add tags
- The table name the domain classes use is customizable
- Utilizes extensive caching to improve performance
- Proper use of packages to avoid domain conflicts
Requirements
Grails Version: 1.1 and above JDK: 1.5 and aboveInstallation
grails install-plugin taggable
Usage
Implement theTaggable interface:import org.grails.taggable.*class Vehicle implements Taggable { }
def v = Vehicle.get(1)v.addTag("red") .addTag("sporty") .addTag("expensive")
def v = Vehicle.get(1) println v.tagsdef vehicles = Vehicle.findAllByTag("sporty") def count = Vehicle.countByTag("sporty")assert 3 == Vehicle.totalTags assert ['expensive', 'red','sporty'] == Vehicle.allTags
def tags = "red,sporty,expensive" def v = Vehicle.get(1)v.parseTags(tags) assert ['expensive', 'red','sporty'] == v.tagstags = "red/sporty/expensive"v.parseTags(tags, "/") assert ['expensive', 'red','sporty'] == v.tags
grails.taggable.tag.table="MY_TAGS" grails.taggable.tagLink.table="MY_TAG_LINKS"