Hi I''m working with rails 2.1.0 and with nested resources. My links i generate with the following helper: link_to @state.name, [@country, @state] Everything works fine and the urls are correctly generated. But now I''d like to add an additional parameter to the url like: /country/1/state/2?category=2 The additional parameter will only be used for filtering in the show action, so I don''t want to add a new nested route. How can I generate an URL with such a parameter? I did not find any solution to this problem... Thanks very much for your help! Julian --~--~---------~--~----~------------~-------~--~----~ 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 Sat, Jul 26, 2008 at 3:21 AM, Julian <webmaster-4v51N2rh+YbNP9cWvQ4C4g@public.gmane.org> wrote:> > Hi > > I''m working with rails 2.1.0 and with nested resources. > > My links i generate with the following helper: > > link_to @state.name, [@country, @state] > > Everything works fine and the urls are correctly generated. > > > But now I''d like to add an additional parameter to the url like: > /country/1/state/2?category=2url_for @state.name, [@country, @state], :category => 2 will do the trick -- Gabriel Laskar <bibi.skuk-Re5JQEeQqe8AvxtiuMwx3w@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 -~----------~----~----~----~------~----~------~--~---
On 27 Jul., 18:37, "Gabriel Laskar" <bibi.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Sun, Jul 27, 2008 at 6:00 PM, Julian <webmas...-4v51N2rh+YbNP9cWvQ4C4g@public.gmane.org> wrote: > > > On 26 Jul., 14:57, "Gabriel Laskar" <bibi.s...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> On Sat, Jul 26, 2008 at 3:21 AM, Julian <webmas...-4v51N2rh+YbNP9cWvQ4C4g@public.gmane.org> wrote: > > >> > Hi > > >> > I''m working with rails 2.1.0 and withnestedresources. > > >> > My links i generate with the following helper: > > >> > link_to @state.name, [@country, @state] > > >> > Everything works fine and the urls are correctly generated. > > >> > But now I''d like to add anadditionalparameterto the url like: > >> > /country/1/state/2?category=2 > > >> url_for @state.name, [@country, @state], :category => 2 > > >> will do the trick > > > But url_for expects only oneparameter... Do I have the wrong rails > > version?? > > Yes, It take only 1 argument, but, if you use > > link_to @state.name, country_state_path(@country, @state, :catergory => 2) > > thats seems to work (a bit tested this time :) ) but it is a bit longer. > > hope it will workThat really works, thanks! Unfortunately I''d like to use the link_to helper with the array notation [@country, @state], because the resource is polymorphic. With link_to(@state.name, [@country, @state], :catergory => 2), catgory is added as an attribute to the HTML link-tag. Do you have an other idea? A workaround would be to write a new link_to helper... Julian --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---