Hi, I have a question about routing and nested resources. I have an app with Photos that belong to Users via a many2one relationship. The URL:
lists all photos (from all users). Clicking on a random photo from this listing should send one to f ex:
http://localhost:3000/users/2/photos/10
Because I have this in my routes.rb:
map.resources :users, :member => { :enable => :put } do |users| users.resources :photos, :name_prefix => 'user_', :controller => 'user_photos', :member => { :add_tag => :put, :remove_tag => :delete } end
However when I load http://localhost:3000/photos I get this error message:
user_photo_url failed to generate from {:controller=>"user_photos", :action=>"show", :user_id=>nil, :id=>#<Photo id: 2, user_id: nil, title: nil, body: nil, created_at: "2008-10-27 14:26:32", etc
Extracted source (around line #2):
1: <li> 2: <%= link_to image_tag(photo.public_filename('thumb')), user_photo_path(:user_id => photo.user, :id => photo) %> 3: </li>
The above partial, _photo.rhtml, is what causes the error.
This code has worked fine up until I refactored it to function with will_paginate instead of classic_pagination. I haven't touched the routing declarations or the _photo.rhtml partial.
Any help will be appreciated!
/ Vahagn