views:

33

answers:

1

I have a widget that has many links. In the routes file:

map.resources :widgets, :has_many => [:links]

I want to add a "sort" action to links. What do I need to add to the routes file, so I can write sort_widget_links_path(widget)

Thanks,

Deb

+2  A: 

You can define it using a block:

map.resources :widgets do |widget|
  widget.resources :links, :member => {:sort => :get}
end
mark
Hi Mark, thank you for your response. Is it ok to define map.resources :widgets twice or do I have to put everything else related to the widgets routes in the same block?
deb
Hi deb. You should really use the same block; though I would probably be ok to do otherwise I can't really understand why you would want to. What else is it you need to define?
mark