:params => params does not work :-(

Hello
I’m applying some filter functionallity to my controller and would
like to have pagination and params sendt without using sessions.
My filter works and it is sent so I can use it like this:

params[:filter][:filter_a]
params[:filter][:filter_b]
and so on.

This works fine, but problem start when I use pagination and would
like to send the params array to the next page.

So I do something like this:
<%= link_to ‘Next’, { :page => @myObjects_pages.current.next, :params
=> params } %>

When I do this the link does not work. It seems it is changed from:
http://myhost/mycontroller;filter?filter[filter_a]=X
to:
http://myhost/mycontroller;filter?page=2&filter=filter_aX

Any easy fixes here?

/Frode

MartOn wrote:

like to send the params array to the next page.
Any easy fixes here?

/Frode

Frode, why do not you try with:
<%= link_to ‘Next’, { params.merge({:page =>
@myObjects_pages.current.next}) } %>

hope that helps…
Bojan


Bojan M.
-> Ruby on Rails and Web D. Blog : http://source.mihelac.org

It is DRY’er, but it still does not work
Still the %5B and the %5D and the = signs are gone…
It seems it does not support multi dimension params array…

/Frode

On Tue, 2007-03-06 at 05:07 -0800, MartOn wrote:

like to send the params array to the next page.
Any easy fixes here?


I’m not sure that I would personally do this but…

params => @params

should probably work


Craig W. [email protected]

Generates the same problem as mentioned in my first post.
the params array holds all information, but I need to know how to
konvert it correctly to :params.

/MartOn

So I do something like this:
<%= link_to ‘Next’, { :page => @myObjects_pages.current.next, :params
=> params } %>

When I do this the link does not work. It seems it is changed from:
First you have to understand what’s going on here so you can fix it.
what you are doing with “link_to” is generating a plain old anchor
(link) object in your html, so it’s going to be difficult to pass any
value other than a string (or something easy to convert to string).

One solution you can try is to serialize it with Marshal.dump(params)
and then in the controller restore it with Marshal.restore. I’m not sure
what kind of string you would obtain from Marshal and also not sure if
link_to is smart enough to escape the char sequence is necessary. If you
find any issues about that, then you should Marshall then escape, and in
the controller first unescape and then restore the object.

good luck!

javier ramirez

Estamos de estreno… si necesitas llevar el control de tus gastos
visita http://www.gastosgem.com !!Es gratis!!

Interesting… I will have a look at it.
But I believe there must be some kind of functionality already in
Rails.
All this params management works inside the form_for. I create for
instance a text_field ‘filter’, ‘filter_a’
and rails will send and handle the params handling for me… My problem
is to send the same variables from a link and not from inside the
form.
PS! I’m using the Restful way and the form action uss GET instead of
POST.

Ï have been thinking of changing the next link to a form button, but I
would like to do it the Rails way…

Any1 knows about good examples/tutorials of filters in rails?

/Frode

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