Forum: Ruby on Rails mySQL paginate syntax question for complex SQL. (over 117 vi

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Jason K. Jackson (Guest)
on 2006-06-12 02:19
(Received via mailing list)
I have this code in my controller and i cannot seem to figure out how to
it to paginate correctly..  Is there a trick to do something like this?
There are a few others at that are having the
issue.  Any incite would be great, thanks in advance!

(over 117 views and no answer in rubyonrailsforum???)

 def display_location
   if params[:search] && params[:search].size > 0
     @listing_pages, @listings = paginate (:listings,
     :per_page => 10,
     :order => "budget desc")
     locations = (params[:search] || {:default =>
|x| '"' + x + '"' }
     conditions = '["station = ?", ' + locations.join(",") + "]"
     @listings = Listing.find(:all, :conditions => "station IN (" +
locations.join(",") + ")")
     flash[:notice] = "There are no listings in this search"

How can this code be made to paginate properly, is it a session issue of
sorts?  If so, how can i maintain session in between the @listing_pages
and the "@listings = Listing.find(:all, :conditions =>" line?   Anyone?
Thanks for your time!
This topic is locked and can not be replied to.