I sometimes need to pass additional parameters to the page at the URL. In the past, I have done this with several generic placeholders in the routes file, which I call "genus" and "view". This worked, but now he began to create URLs with query strings.
Rails version is 2.3.8.
Route File:
ActionController::Routing::Routes.draw do |map|
map.root :controller => 'main', :action => 'index'
map.connect ':controller', :action => 'index'
map.connect ':controller/:action'
map.connect ':controller/:action/:id'
map.connect ':controller/:action/:genus/:id'
map.connect ':controller/:action/:genus/:species/:id'
end
Index Page:
<p>
<%= url_for :controller => 'main', :action => 'test', :genus => 42, :id => 1 %>
</p>
Testing Page
<p>
<%= params.inspect -%>
</p>
Does the index page display / main / test? genus = 42 & id = 1 , where I would expect / main / test / 42/1 .
However, if I go to / main / test / 42/1 , then I see the correct options:
{ "controller" = > "main", "action" = > "test", "genus" = > "42", "id" = > "1" }
, ?