Problem with paginate and conditions


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
but if i get it into @form variable, and try
it throws error about nil object, where array is expected. What’s wrong?

Ok i figured out that it was rather stupid to pass nested hash in url :slight_smile:

But is there a smart way to pass conditions parameters for paginate, so
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 forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs