Forum: Ruby on Rails Problem with paginate and conditions

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.
Szymon N. (Guest)
on 2006-04-05 21:13
Hi!

I have a search form that calls search action, which executes paginate
method with many conditions using data from the form.

Now if all results don't fit into a single page, do i have to send all
conditions again to paginate method in link_to previous/next?
If yes, how? All my parameters from the search form are inside a
(nested) hash called 'form' so i tried to do something like this:
@form = params[:form]

and later in the view pass it in
link_to 'next', {:page => ..., :form => @form}

but i get all parameters in the url one after another
(var1value1var2value2) and not like this: ?var1=value1&var2=value2.


Another thing: if i get a hash from params as controller only variable
form = params[:form]
i can do
form[:typ].keys
but if i get it into @form variable, and try
@form[:typ].keys
it throws error about nil object, where array is expected. What's wrong?
Szymon N. (Guest)
on 2006-04-06 01:45
Ok i figured out that it was rather stupid to pass nested hash in url :)

But is there a smart way to pass conditions parameters for paginate, so
i
won't have to manually pass 5 or more paramters in link_to next/previous
and paginatation_links? Is it possible to somehow cache the sql query,
so it will be reused or something like that?
This topic is locked and can not be replied to.