Rails3 路由错误仅在 images#destroy 中 - 我不明白为什么...“没有路由匹配...” - 回形针?
我有一个rails3应用程序,我正在使用jquery-rails.. 我可以删除其他模型的所有对象,但不能删除我的图像。
也许回形针有问题?
images_controller.rb
def destroy
@image = Image.find(params[:id])
@image.destroy
flash[:notice] = "Successfully destroyed image."
redirect_to images_url
end
paths.rb
resources :images do
resources :comments
end
rake 路由
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"}
我的视图文件:
<%= link_to "Delete Image", @image, :confirm => 'Are you sure?', :method => :destroy %>
错误:
routing error
No route matches "/images/8"
我不明白这里的错误在哪里,为什么它只与图像有关?
I have a rails3 application and I am using jquery-rails..
I can delete all the objects of my other models, but not my images.
Maybe an paperclip problem?
images_controller.rb
def destroy
@image = Image.find(params[:id])
@image.destroy
flash[:notice] = "Successfully destroyed image."
redirect_to images_url
end
routes.rb
resources :images do
resources :comments
end
rake routes
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"}
my view file:
<%= link_to "Delete Image", @image, :confirm => 'Are you sure?', :method => :destroy %>
the error:
routing error
No route matches "/images/8"
I don't get where is the error here, and why it is only with the images?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它当然必须是 :method => :删除,而不是:方法 => :破坏
It has of course to be :method => :delete, not :method => :destroy