Jason K. Jackson
2006-Jun-11 22:17 UTC
[Rails] mySQL paginate syntax question for complex SQL. (over 117 views in rubyonrailsforum and no answer, others confused..)
I have this code in my controller and i cannot seem to figure out how to get
it to paginate correctly.. Is there a trick to do something like this?
There are a few others at www.rubyonrailsforum.com that are having the same
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 =>
"someplace"}).values.map{
|x| ''"'' + x + ''"'' }
conditions = ''["station = ?", '' +
locations.join(",") + "]"
@listings = Listing.find(:all, :conditions => "station IN (" +
locations.join(",") + ")")
else
flash[:notice] = "There are no listings in this search"
end
end
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 line
and the "@listings = Listing.find(:all, :conditions =>" line?
Anyone?
Thanks for your time!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060611/efd9c37d/attachment.html
