我有一个 rails3 应用程序,我正在使用 jquery-rails.. 我可以删除我其他模型的所有对象,但不能删除我的图像。
也许是回形针问题?
图像 Controller .rb
def destroy
@image = Image.find(params[:id])
@image.destroy
flash[:notice] = "Successfully destroyed image."
redirect_to images_url
end
路线.rb
resources :images do
resources :comments
end
耙路
images GET /images(.:format) {:action=>"index", :controller=>"images"}
POST /images(.:format) {:action=>"create", :controller=>"images"}
new_image GET /images/new(.:format) {:action=>"new", :controller=>"images"}
edit_image GET /images/:id/edit(.:format) {:action=>"edit", :controller=>"images"}
image GET /images/:id(.:format) {:action=>"show", :controller=>"images"}
PUT /images/:id(.:format) {:action=>"update", :controller=>"images"}
DELETE /images/:id(.:format) {:action=>"destroy", :controller=>"images"}
我的 View 文件:
<%= link_to "Delete Image", @image, :confirm => 'Are you sure?', :method => :destroy %>
错误:
routing error
No route matches "/images/8"
我不明白这里的错误在哪里,为什么只出现在图片上?
最佳答案
它当然必须是 :method => :delete,而不是 :method => :destroy
关于javascript - Rails3 Routing Error only in images#destroy - 我不明白为什么... "no route matches..."- 回形针?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5900310/