I have a nested resources like this
resources :profiles do
resources :albums do
resources :images
end
end
match ':username' => "profiles#show", :as => 'profile'
so as example the url of specific image is
http://localhost:3000/profiles/Azzurrio/albums/4/images/1
I can’t use profile username inside my template, when I use params[:username] it doesn’t work, so can anyone tell me how can I deal with this params?
This page (look for “nested routes”) tells you what you want.
In short, if you have the nested resource structure you’ve defined above, then the url will contain this structure:
profiles/:profile_id/albums/:album_id/images/:image_idSo you’re looking for
params[:profile_id]