I have nested resources like so
resources :users do
resources :widgets
end
When I have @widget, to get a proper routing from my helpers i need to use user_widget_path(@widget.user, @widget) is there any way to tell rails to automatically pull out the user from @widget object? So i could just use user_widget_path(@widget)
@apneadiving is totally right. But you can improve a little your approach:
can be presented shorter:
UPD
Also you can rewrite
user_widget_pathas you want:You should also rewrite
edit_user_widget_path,new_user_widget_path. And better to wrap it as an external Module.