> · Are the new entries at the bottom of routes.rb done in the
> correct way? They work, but again, there’s a little too much
> repetition for my liking
Typically, we've been trying to stick with restful routes, though the
more people that have put there hands in, the more variation we've
gotten...
If it were me, I would make those "member" actions of the existing
projects resource (line 217). This is what's currently there:
map.resources :projects,
:path_prefix => "/bus_admin",
:name_prefix => "bus_admin_",
:controller => "bus_admin/projects",
:active_scaffold => true
This is what I would make it (just adding another line, basically):
map.resources :projects,
:path_prefix => "/bus_admin",
:name_prefix => "bus_admin_",
:controller => "bus_admin/projects",
:active_scaffold => true,
:member => { :embedded_budget_items
=> :get, :embedded_milestones => :get, :embedded_key_measures
=> :get, :embedded_you_tube_videos => :get, :embedded_flickr_images
=> :get }
Then you can remove the routes you've added altogether. That gets you
all the same functionality, but using the existing routes rather than
creating some manually. As an added bonus, this also creates some
named routes for you:
embedded_budget_items_bus_admin_project_path(1) # 1 being the project_id
embedded_milestones_bus_admin_project_path(1)
embedded_key_measures_bus_admin_project_path(1)
embedded_you_tube_videos_bus_admin_project_path(1)
embedded_flickr_images_bus_admin_project_path(1)
I know that's a fair bit to grok all at once, but you can read here
for more explicit info:
http://api.rubyonrails.com/classes/ActionController/Resources.html
(look at the info in the resources method as well as the stuff at the
top) |