收到此錯誤:Ruby on Rails的:創建刪除鏈接關聯對象
undefined method `to_model' for #<Paperclip::Attachment:0x007fc5d1c46e60>
我試圖創建一個刪除鏈接到我的相關圖像
<% @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 %>
我的模型
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
我相信我的image.photo
是錯的,但我不確定它應該是什麼?我想我應該確定路徑是什麼?但是我沒有ProjectImages的路線。我只通過嵌套屬性保存圖像。我真的需要創建一個新的路線嗎?如果是這樣,它會是什麼?
編輯(添加路由)
這是我的路線:
resources :projects do
member do
get 'add_photos'
post 'upload_photos'
end
end
您可以發佈您耙路由的詳細信息。 –
@bipashant嗨,我說我的路線,這是什麼在我的路線,涉及到項目 – hellomello