0
我正在使用activeadmin的car
資源和多個附件沒有進入記錄,car
記錄創建成功,但在創建時它不包含附件。我有兩個型號「附件」,models/attachment.rb
Activeadmin多態關聯,回形針附件
class Attachment < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
has_attached_file :avatar, styles: { medium: "300x300>", thumb: "100x100>" },default_url: "/images/:style/missing.png"
validates_attachment_content_type :avatar, content_type: /\Aimage\/.*\Z/
end
而且 和我model/car.rb
包含下面的代碼
class Car < ActiveRecord::Base
has_many :attachments, as: :imageable
accepts_nested_attributes_for :attachments
end
,在我app/admin/car.rb
我爲多個連接下面的代碼。
form do |f|
f.input :make
f.input :model
f.input :color
f.input :engine_type
f.input :description
f.has_many :attachments do |attachment|
attachment.input :attachment, :as => :file
end
f.actions
end
任何人都可以請解釋如何解決這個問題?
可以顯示你permit_params你'管理員/ car.rb'? – nayiaw
當您嘗試保存/創建記錄時,日誌文件會說明什麼? – Eric