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%5Bfilter_a%5D=X to: http://myhost/mycontroller;filter?page=2&filter=filter_aX Any easy fixes here? /Frode --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
MartOn wrote:> 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%5Bfilter_a%5D=X > to: > http://myhost/mycontroller;filter?page=2&filter=filter_aX > > 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 Mihelac -> Ruby on Rails and Web Developer Blog : http://source.mihelac.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 Mar 6, 4:52 pm, Bojan Mihelac <l...-3SxN1WY3PMJAfugRpC6u6w@public.gmane.org> wrote:> MartOn wrote: > > 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%5Bfilter_a%5D=X > > to: > >http://myhost/mycontroller;filter?page=2&filter=filter_aX > > > 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 Mihelac > -> Ruby on Rails and Web Developer Blog :http://source.mihelac.org--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Tue, 2007-03-06 at 05:07 -0800, MartOn wrote:> 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%5Bfilter_a%5D=X > to: > http://myhost/mycontroller;filter?page=2&filter=filter_aX > > Any easy fixes here?---- I''m not sure that I would personally do this but... params => @params should probably work -- Craig White <craig-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Mar 6, 7:16 pm, Craig White <c...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org> wrote:> On Tue, 2007-03-06 at 05:07 -0800, MartOn wrote: > > 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%5Bfilter_a%5D=X > > to: > >http://myhost/mycontroller;filter?page=2&filter=filter_aX > > > Any easy fixes here? > > ---- > I''m not sure that I would personally do this but... > > params => @params > > should probably work > > -- > Craig White <c...-CnJ8jr4MGtxl57MIdRCFDg@public.gmane.org>--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> 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!! --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
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 On Mar 6, 8:51 pm, javier ramirez <jrami...-7iWCczGtl7hBDgjK7y7TUQ@public.gmane.org> wrote:> > 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 visitahttp://www.gastosgem.com!!Es gratis!!--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---