/ Published in: Groovy
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
tagsForUser1 = ['tag1','tag2']
tagsForUser2 = ['tag1']
u1 = User.findByName('user1')
u2 = User.findByName('user2')
//ITEM1 ***************************************************
item1.user = u1
tagsForUser1.each {
t = Tag.findByName(it)
}
}
//ITEM2 **************************************************
item2.user = u2
tagsForUser2.each {
t = Tag.findByName(it)
}
}
}
//setup()
t = Tag.findByName('tag1')
itemsForUserAndTag = Taggable.withCriteria {
and {
eq('user', u2)
tags {
eq('tag', t)
}
}
}
itemsForTag = Taggable.withCriteria {
tags {
eq('tag', t)
}
}
println "Items for user and tag: $itemsForUserAndTag.name"
println "Items for tag: $itemsForTag.name"
Comments
 Subscribe to comments
                    Subscribe to comments
                
                