Matt-pow
Matt-pow

Reputation: 986

Ruby rails change browser url with resources

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

Upvotes: 0

Views: 154

Answers (1)

Phillip Musiime
Phillip Musiime

Reputation: 527

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?

Upvotes: 1

Related Questions