What is the name of params for nested resources

I have nested resources like

resources :profiles do
    resources :albums do
      resources :images 
    end
  end
match ':username' => "profiles#show", :as => 'profile'

so an example of a specific image url

http://localhost:3000/profiles/Azzurrio/albums/4/images/1

I can’t use the profile username inside my template, when I use params [: username], it doesn’t work, so can someone tell me how I can handle these parameters?

+3
source share
2 answers

This page (search for "nested routes") tells you what you want.

In short, if you have a nested resource structure that you defined above, then the url will contain this structure:

profiles/:profile_id/albums/:album_id/images/:image_id

So you are looking params[:profile_id]

+8
source

rake routes, param.

+3

All Articles