masta Blasta wrote in post #1140924:
Well i discovered a potential routing solution. Now i can forward
everything to the same actions (again this is Rails 2.3)
map.resources :reports do |reports|
reports.technical_overview 'technical_overview',
:controller => 'reports',
:action => 'show_section',
:section_name=>'technical_overview',
:conditions => {:method=>:get}
reports.functional_overview 'functional_overview',
:controller => 'reports',
:action => 'show_section',
:section_name=>'functional_overview',
:conditions => {:method=>:get}
reports.update_technical_overview 'technical_overview',
:controller => 'reports',
:action => 'update_section',
:section_name=>'technical_overview',
:conditions => {:method=>:post}
end
This actually makes me quite happy. I found out that any unrecognized
options passed to the route mapper just get forwarded to the action
params. This allows the generated path helpers to be used without any
additional arguments, and is more backwards compatible with what i have
now.
The shorter alternative would be to do
reports.section ':section_name',
:controller => 'reports',
:action => 'show_section',
:conditions => {:method=>:get}
but then every time you call the path helper you would have to specify
the :section_name as an additional argument. Which is not as nice.
This gets me 90% of the way there, but I would still like to hear what
other solutions there are to this problem.