Reputation: 11171
I just introduced a join table to add Plants
to Gardens
and I'm trying to implement this in my first-ever rails app. I want to
Add a Plant to a Garden
This seems like a nice restful path: /plants/{id}/add_to_garden/{garden_id}
, but I'm having trouble figuring out how to write that route.
This makes sense to me, but it doesn't work:
resources :plants do
member do
post 'add_to_garden/:garden_id'
end
end
Upvotes: 0
Views: 26
Reputation: 3610
One possible way is:
post 'plants/:id/add_to_garden/:garden_id' => 'plants#add_to_garden', as: :add_to_garden
Upvotes: 1