开发者

Problem with deleting a photo object

开发者 https://www.devze.com 2023-01-27 22:43 出处:网络
I have this in my view, <% @photos.each do |photo| %> <%= link_to \"Destroy\", photo, :method => \"delete\" %>

I have this in my view,

<% @photos.each do |photo| %>
  <%= link_to "Destroy", photo, :method => "delete" %>
<% end %>

And I get an undefined method `photo_path' error.

I'm using paperclip.

And here's the extract from my rake routes.

DELETE /admin/issues/:issue_id/photos/:id(.:format) {:action=>"destroy",controller=>"admin/photos"}

Thanks!

UPDATE

  map.resources :issues, :has_many => [:notes, :photos]

  map.namespace :admin do 开发者_如何学Python|admin|
    admin.resources :issues 
    admin.resources :issues do |issue|
      issue.resources :photos
    end
  end


Have you mapped :photo as a resource in your routes.rb?


UPDATE

Based on your routes, maybe this would work:

<% @photos.each do |photo| %>
  <%= link_to "Destroy", admin_issue_photo_path(photo), :method => "delete" %>
<% end %>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号