Thanks for Mark for the ‘tuning’. Now that I think of this, can I add
another associated table (reviews) and include that into the search
also? What I mean is that if the models are
Person
has_many :readings
has_many :books, :through => :readings
has_many :reviews
Reading
belongs_to :person
belongs_to :book
Book
has_many :readings
has_many :persons, :through => :readings
Review
belongs_to :person
Now I would like to form a search like below
Person.find(:all,
:conditions => [“people.name LIKE ? AND
books.name LIKE ? AND
reviews.rating LIKE ?”,
“%#{params[:person_name]}%”,
“%#{params[:book_name]}%”,
“%#{params[:rating]}%”])
Person.find(:all,
:conditions => [“people.name LIKE ? AND
books.name LIKE ? AND
reviews.rating LIKE ?”,
“%#{params[:person_name]}%”,
“%#{params[:book_name]}%”,
“%#{params[:rating]}%”])