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].
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>