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 

路线.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"}

我的视图文件:

 <%= link_to "Delete Image", @image, :confirm => 'Are you sure?', :method => :destroy %> 

错误:

routing error
No route matches "/images/8"

我不明白这里的错误在哪里,为什么它只与图像有关?

4

1 回答 1

0

它当然必须是 :method => :delete,而不是 :method => :destroy

于 2011-05-07T10:43:21.377 回答