hellomello
hellomello

Reputation: 8597

Rails: custom routes nested custom routes?

Can I do custom routes nested within a custom route already?

Say

localhost:3000/prof/3

with

match 'prof/:id' => 'professionals#show', :as => :prof

I'd like to do more custom routes:

localhost:3000/prof/3/services/2

Right now I have this:

resources :professionals do
  resources :services, :defaults => { :servicable => 'professional' }
end

this gives me something like:

/professionals/:professional_id/services/:id

I'm still learning rails methods.

Upvotes: 1

Views: 139

Answers (1)

Jonathan Bender
Jonathan Bender

Reputation: 1909

You can simply specify the path option for your resource to put it at a specific location.

resources :professionals, path: '/prof' do
  resources :services, :defaults => { :servicable => 'professional' }
end

Upvotes: 2

Related Questions