Yogi wrote:
> 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]}%"])
>
> How would I use :joins to make the above to work?
Use the :joins option just like :include. So
:joins => [:books, :reviews]
--
Rails Wheels - Find Plugins, List & Sell Plugins - http://railswheels.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---