0

I have a nested resources:

resources :topic do
    resource :fruits, only: [:edit, :update]
end

I want the browser url to be /topic/:topic_id/fruits(.:format) (without /edit) instead of /topic/:topic_id/fruits/edit(.:format)

In my action controller I see I have these routes

GET /topic/:topic_id/fruits/edit
fruits#edit

PATCH /topic/:topic_id/fruits/
fruits#update

PUT /topic/:topic_id/fruits/
fruits#update
Matt-pow
  • 946
  • 4
  • 18
  • 31
  • Why not just put the form on the `show` view if thats the requirement? While you can certainly route `/topic/:topic_id/fruits` to `topics#edit` its quirky and unconventional. The only reason really that the edit action exists in the conventions is to have a separate view with the form. – max Aug 10 '21 at 11:41

1 Answers1

1

what you are looking for is called a member route and it is well explained here difference between collection route and member route in ruby on rails?

Phillip Musiime
  • 167
  • 2
  • 12