1
我在我的數據庫中有一個名爲product的模型。它有很多照片。如何在圖片url中創建記錄照片
has_many :photos, as: :imageable, dependent: :destroy
我的照片我的模型看起來是這樣的:
class Photo < ActiveRecord::Base
belongs_to :imageable, polymorphic: true
mount_uploader :image, AttachmentUploader
end
我想補充的產品P1的照片,我不想以前下載的照片,但通過它的URL來代替,smething像:
Photo.create(image: URI.parse("http://www.zdenka.hr/wp-content/uploads/2013/10/classic.png"), imageable: p1)
但是,image設置爲零。我該如何解決?