Getting this error:
undefined method `to_model' for #<Paperclip::Attachment:0x007fc5d1c46e60>
I'm trying to create a remove link to my associated image
<% @project.project_images.each do |image| %>
<%= image_tag image.photo.url(:thumb) %>
<div class="actions">
<%= link_to "remove", image.photo, confirm: "Are you sure?", method: :delete %>
<% end %>
My Model
class Project < ActiveRecord::Base
has_many :project_images, dependent: :destroy
accepts_nested_attributes_for :project_images, allow_destroy: true
end
class ProjectImage < ActiveRecord::Base
belongs_to :project
end
I believe my image.photo is wrong, but I'm not sure what it should be? I guess I should determine what the path is? But I don't have a routes for ProjectImages. I'm only saving the images through nested attributes. Do I really need to create a new routes? If so, what would it be?
EDIT (Adding Routes)
This is my routes:
resources :projects do
member do
get 'add_photos'
post 'upload_photos'
end
end