这是路线的相关部分:
resources :photos, :path => '', :only => [:show, :new, :create, :destroy, :edit] do
...
end
我被添加到视图中删除照片的链接:
<%= button_to 'Delete', @photo, :method => :delete, :confirm => 'Are you sure?' %>
但是这个视图返回错误:
undefined method `photo_path' for #<#<Class:0x007faef8172060>:0x007faef87a7908>
destroy方法是脚手架生成的方法。我有什么问题?
编辑: rake routes
输出:
root / photos#index
search GET /search(.:format) photos#search
voteup_user_photo GET /:user_id/:id/voteup(.:format) photos#voteup
votedown_user_photo GET /:user_id/:id/votedown(.:format) photos#votedown
user_photos POST /:user_id(.:format) photos#create
new_user_photo GET /:user_id/new(.:format) photos#new
edit_user_photo GET /:user_id/:id/edit(.:format) photos#edit
user_photo GET /:user_id/:id(.:format) photos#show
DELETE /:user_id/:id(.:format) photos#destroy