hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2007-Mar-26 12:21 UTC
how to pass"page" parameter to xxx_path or xxx_url
Dear all, In my app, i uses named route to point to a list page. This is a paginated list. I try to go to a specific page by passing the "page" parameter to the xxx_path method in link_to call, but this method doesn''t accept additional hash. So my question is is there a way to construct a link to a specific page in pagination using xxx_path method? Thanks, - Chuong --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Jason Roelofs
2007-Mar-26 13:06 UTC
Re: how to pass"page" parameter to xxx_path or xxx_url
Use xxx_url(params). Jason On 3/26/07, hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Dear all, > > In my app, i uses named route to point to a list page. This is a > paginated list. I try to go to a specific page by passing the "page" > parameter to the xxx_path method in link_to call, but this method > doesn''t accept additional hash. So my question is is there a way to > construct a link to a specific page in pagination using xxx_path > method? > > Thanks, > - Chuong > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
xxx_path(:id => @mymodel.id) xxx_url(:id => @mymodel.id) On 3/26/07, hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Dear all, > > In my app, i uses named route to point to a list page. This is a > paginated list. I try to go to a specific page by passing the "page" > parameter to the xxx_path method in link_to call, but this method > doesn''t accept additional hash. So my question is is there a way to > construct a link to a specific page in pagination using xxx_path > method? > > Thanks, > - Chuong > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Trevor Squires
2007-Mar-26 16:37 UTC
Re: how to pass"page" parameter to xxx_path or xxx_url
Hey, the standard method is to pass a hash for everything instead of using positional parameters: foos_path(:parent_id => ''a_parent'', :page => 2) An alternative is to use my resource_fu plugin [1] which does allow mixing of positional and hash parameters in your url helpers - though that''s not the *only* change to url helpers that it makes so you may want to check out the README file to make sure its not introducing behavior you''d rather not have. Regards, Trevor [1] - http://agilewebdevelopment.com/plugins/resource_fu On 26-Mar-07, at 5:21 AM, hnchuong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > Dear all, > > In my app, i uses named route to point to a list page. This is a > paginated list. I try to go to a specific page by passing the "page" > parameter to the xxx_path method in link_to call, but this method > doesn''t accept additional hash. So my question is is there a way to > construct a link to a specific page in pagination using xxx_path > method? > > Thanks, > - Chuong > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi, I''ve applied your suggestion, but instead of taking parameters which match the named route description and only put the remained parameters in the format of param1=value1¶m2=value2..., it put all parameters under that format. Luckily in my case, the value of parameters in named route get inherited from the current url so I just left out those parameters in the xxx_path call, and it works now. However, I still want to know in the case which these parameters not inherited, how can we pass all parameters. Thank you for your help. - Chuong On Mar 26, 11:37 pm, Trevor Squires <tre...-k8q5a0yEZAgS+FvcfC7Uqw@public.gmane.org> wrote:> Hey, > > the standard method is to pass a hash for everything instead of using > positional parameters: > > foos_path(:parent_id => ''a_parent'', :page => 2) > > An alternative is to use my resource_fu plugin [1] which does allow > mixing of positional and hash parameters in your url helpers - though > that''s not the *only* change to url helpers that it makes so you may > want to check out the README file to make sure its not introducing > behavior you''d rather not have. > > Regards, > Trevor > > [1] -http://agilewebdevelopment.com/plugins/resource_fu > > On 26-Mar-07, at 5:21 AM, hnchu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote: > > > > > Dear all, > > > In my app, i uses named route to point to a list page. This is a > > paginated list. I try to go to a specific page by passing the "page" > > parameter to the xxx_path method in link_to call, but this method > > doesn''t accept additional hash. So my question is is there a way to > > construct a link to a specific page in pagination using xxx_path > > method? > > > Thanks, > > - Chuong--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---