Shreyas
Shreyas

Reputation: 8757

Problem with deleting a photo object

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 |admin|
    admin.resources :issues 
    admin.resources :issues do |issue|
      issue.resources :photos
    end
  end

Upvotes: 0

Views: 131

Answers (1)

hade
hade

Reputation: 1715

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 %>

Upvotes: 1

Related Questions