Forum: Ruby on Rails Pagination issue because of join

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
B72610c28afc18f4b817770c8b9accd8?d=identicon&s=25 Neeraj Kumar (Guest)
on 2006-04-23 07:01
(Received via mailing list)
My current code is like this:

    query = "desc_uf like '%" + session[:search_term] + "%'"
    @event_pages, @events = paginate :events, :per_page => 10
,:conditions   => query ,:order => "start_date DESC"


This query is made against table 'EVENTS' and everything works fine.


Now the query gets complex. I need to make a join to a different table
namely 'STATES'. The 'EVENTS' table has a column named 'VENUE_ID'.
'VENUE'
table has a column named 'STATE_ID'. 'STATES' table has the primary
column
'ID'.

How do I retrieve events only belonging to a particular state using
pagination?


Thanks.
This topic is locked and can not be replied to.