CodeGuy
CodeGuy

Reputation: 28907

Reorganizing Ruby URLs

In my Ruby on Rails web application, I have the files:

app/models/big.rb
app/controllers/big_controller.rb
app/models/small.rb
app/controllers/small_controller.rb

Links such as http://localhost:8080/big/1 and http://localhost:8080/small/ work great but I want to be able to have a link such as

http://localhost:8080/big/1/small 

How do I set up routes to do this? I would like to not have to go through and update all paths (ex. small_path)

Upvotes: 0

Views: 58

Answers (1)

Ismael
Ismael

Reputation: 16720

You can do something like this (nested routes/resources)

resources :big do
  resources :small
end

http://guides.rubyonrails.org/routing.html#nested-resources

Upvotes: 1

Related Questions