Find all items which have these tags

Hi

This works:
Item.find(:all, :include => ‘tags’, :conditions => [“tags.name =
?”,“Rainproof”])

This works as well:
Item.find(:all, :include => ‘tags’, :conditions => “tags.name in
(‘Rainproof’,‘Bowl’)”)
(Here without substitution.)

How to find the items which have a tag with name “Rainproof” AND a tag
with name “Bowl”?

Tobi


http://www.rubynaut.com/

Tobi R. wrote:

Hi

This works:
Item.find(:all, :include => ‘tags’, :conditions => [“tags.name =
?”,“Rainproof”])

This works as well:
Item.find(:all, :include => ‘tags’, :conditions => “tags.name in
(‘Rainproof’,‘Bowl’)”)
(Here without substitution.)

How to find the items which have a tag with name “Rainproof” AND a tag
with name “Bowl”?

Not sure if this will work, as I’m not very good at SQL anymore…

Item.find(:all, :include => :tags, :conditions => [ 'tags.name = ? AND
tags.name = ? ], ‘Rainproof’, ‘Bowl’ ])

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs