I''m implementing an action that needs two parameters in the url like do/a/b and in the controller I would like to access a and b like params[:id] Please let me know if there''s any solution. THanks Abon -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bontina Chen wrote:> I''m implementing an action that needs two parameters in the url like > > do/a/b > > and in the controller > I would like to access a and b > > like params[:id] > > Please let me know if there''s any solution.In routes.rb create something like: map.connect ''do/:a/:b'', :controller => "do", :action => "index" In controller "do" :a and :b will be accessible as params[:a] and params[:b]. -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
THanks for the solution. Btw, it seems not ok to have tow ids in link_to. Abon Michael Wang wrote:> Bontina Chen wrote: >> I''m implementing an action that needs two parameters in the url like >> >> do/a/b >> >> and in the controller >> I would like to access a and b >> >> like params[:id] >> >> Please let me know if there''s any solution. > > In routes.rb create something like: > > map.connect ''do/:a/:b'', :controller => "do", :action => "index" > > In controller "do" :a and :b will be accessible as params[:a] and > params[:b]. > > > -- > Michael Wang-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Bontina Chen wrote:> THanks for the solution. > Btw, it seems not ok to have tow ids in link_to.In the link_to helper method, any parameters that you specify will be matched to the route that Rails is going to use, and any "extra" parameters (parameters not named in the route) will be tacked on as URL query parameters. So you can do: link_to "link name", :controller => "do", :action => "index", :a => "a_blah", "b => "b_blah", :c => "c_blah" and you get (using the route in my previous post): <a href="/do/a_blah/b_blah?c=c_blah">link_name</a> -- Michael Wang --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---