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]
source
share