Rails3 路由错误仅在 images#destroy 中 - 我不明白为什么...“没有路由匹配...” - 回形针?

发布于 2024-11-05 00:25:04 字数 1613 浏览 9 评论 0原文

我有一个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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

对你的占有欲 2024-11-12 00:25:04

它当然必须是 :method => :删除,而不是:方法 => :破坏

It has of course to be :method => :delete, not :method => :destroy

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文