Shallow routes dodanie kolejnej sciezki

Routes.rb

map.root :controller => "albums" map.resources :users, :shallow => true do |user| user.resources :albums,:collection => {:delete_multiple => :post} do |album| album.resources :photos, :collection => { :delete_multiple => :post} end end

root / {:controller=>"albums", :action=>"index"} delete_multiple_album_photos POST /albums/:album_id/photos/delete_multiple(.:format) {:controller=>"photos", :action=>"delete_multiple"} album_photos GET /albums/:album_id/photos(.:format) {:controller=>"photos", :action=>"index"} POST /albums/:album_id/photos(.:format) {:controller=>"photos", :action=>"create"} new_album_photo GET /albums/:album_id/photos/new(.:format) {:controller=>"photos", :action=>"new"} edit_photo GET /photos/:id/edit(.:format) {:controller=>"photos", :action=>"edit"} photo GET /photos/:id(.:format) {:controller=>"photos", :action=>"show"} PUT /photos/:id(.:format) {:controller=>"photos", :action=>"update"} DELETE /photos/:id(.:format) {:controller=>"photos", :action=>"destroy"} delete_multiple_user_albums POST /users/:user_id/albums/delete_multiple(.:format) {:controller=>"albums", :action=>"delete_multiple"} user_albums GET /users/:user_id/albums(.:format) {:controller=>"albums", :action=>"index"} POST /users/:user_id/albums(.:format) {:controller=>"albums", :action=>"create"} new_user_album GET /users/:user_id/albums/new(.:format) {:controller=>"albums", :action=>"new"} edit_album GET /albums/:id/edit(.:format) {:controller=>"albums", :action=>"edit"} album GET /albums/:id(.:format) {:controller=>"albums", :action=>"show"} PUT /albums/:id(.:format) {:controller=>"albums", :action=>"update"} DELETE /albums/:id(.:format) {:controller=>"albums", :action=>"destroy"} users GET /users(.:format) {:controller=>"users", :action=>"index"} POST /users(.:format) {:controller=>"users", :action=>"create"} new_user GET /users/new(.:format) {:controller=>"users", :action=>"new"} edit_user GET /users/:id/edit(.:format) {:controller=>"users", :action=>"edit"} user GET /users/:id(.:format) {:controller=>"users", :action=>"show"} PUT /users/:id(.:format) {:controller=>"users", :action=>"update"} DELETE /users/:id(.:format) {:controller=>"users", :action=>"destroy"}
Dostaje sie do poszczegolnego albumu poprzez http://localhost:3000/albums/38/photos
W kazdym albumie mam liste zdjec do ktorych chcialbym sie dostac poprzez http://localhost:3000/albums/38/photo/Id. Potrzebne mi to do przekierowania kiedy wykonam jakas akcje na poszczegolnym zdjeciu np “destroy”. Chce wtedy przekierowac uzytkownika spowrotem do albumu danego zdjecia

[color=#FF0000]Edit[/color]: Narazie poradzilem sobie wyciagajac album_id bezposrednio z tabeli photo

def destroy @photo = Photo.find(params[:id]) @photo.destroy flash[:notice] = "Successfully destroyed photo." redirect_to album_photos_path(@photo.album_id) end

Myślę że nie jest to Ci do niczego potrzebne. W akcji destroy możesz zrobić:

   @photo = Photo.find(params[:id])
   @photo.destroy
   redirect_to album_path(@photo.album)

bądź podobnie, i powinno działać.