Pagination issue because of join


#1

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.