I want to create a custom route such as 'photos/:user_id/:photo_id' for showing each photo. In my routes file I have;
get 'photos/:user_id/:photo_id' => 'photos#show', :as => 'user_photo'
and rake routes gives me
user_photo GET /photos/:user_id/:photo_id(.:format) photos#show
Edit;
Now when I link to a photo using link_to 'some photo', user_photo_path(@photo,@user) I just get the following error
Processing by PhotosController#show as HTML
Parameters: {"user_id"=>"8", "photo_id"=>"8"}
User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = 8 ORDER BY "users"."id" ASC LIMIT 1
Completed 404 Not Found in 3ms
ActiveRecord::RecordNotFound - Couldn't find Photo without an ID:
activerecord (4.1.1) lib/active_record/relation/finder_methods.rb:402:in `find_with_ids'
activerecord (4.1.1) lib/active_record/relation/finder_methods.rb:68:in `find'
activerecord (4.1.1) lib/active_record/querying.rb:3:in `find'
() Users/batman/code/myapp/app/controllers/photos_controller.rb:73:in `set_photo'

user_photo_path(photo_id: @photo.id, user_id: @photo.user_id)