How to add additional rest routes to a nested resource in rails
-
26-09-2019 - |
Question
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)
Solution
You can define it using a block:
map.resources :widgets do |widget|
widget.resources :links, :member => {:sort => :get}
end
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow