Skip to content

rahul/nested_tire_query_problem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

I have the following models.

class Author
    include Tire::Model::Search
    include Tire::Model::Callbacks

    has_many :books
    has_many :tags #(eg: 'german', 'philosopher')
end

class Book
    belongs_to :author
    belongs_to :book_type #(eg: 'paperback', 'hardcover')
    has_many :tags #(eg: 'crime', 'drama')
end

I need help in understanding and writing the following search queries,

Find all authors who

are tagged as 'german' AND 'philosopher'
have written at least 1 book each of book_type 'paperback' AND 'hardcover'
where each such book is tagged as 'crime' AND 'drama'

Find all authors who

are tagged as 'german' AND 'philosopher'
have written at least 1 book of any book_type
where that book is tagged as 'crime' AND 'drama'