You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to create records from a csv file. Each row of the CSV file will be a new record.
defimportads=[]CSV.foreach(file.path,headers: true,encoding: encoding)do |row|
ad=Ad.newad.title=row['title'] || ''ad.description=row['description'] || ''# Ad has_one: variantad.variant_attributes=initialize_ad_variant(row).attributesads << adendAd.import(ads,recursive: true)# I'm using postgres enddefinitialize_ad_variant(row)variant=Variant.new# inside CSV I have a column called 'custom_image_url', which contains an image url from where we need to save the image. # 'custom_image' is the field name in variant table. I'm using carrierwave.variant.remote_custom_image_url=row['custom_image_url']variant.custom_text=row['custom_text']returnvariantend
The above code inserts Ads with associated variants. But seems like the images are not uploaded inside the variant table. Only the custom_text is inserted.
Is there any way to bulk upload nested attributes like this; where the images will be uploaded from remote url?
The text was updated successfully, but these errors were encountered:
Without knowing more of the internals of how the remote images are loading it's hard to give any suggestions. I would say try to find out if there is some type of call you make on each variant to manually load the image before importing.
I'm trying to create records from a csv file. Each row of the CSV file will be a new record.
The above code inserts
Ad
s with associatedvariant
s. But seems like the images are not uploaded inside the variant table. Only thecustom_text
is inserted.Is there any way to bulk upload nested attributes like this; where the images will be uploaded from remote url?
The text was updated successfully, but these errors were encountered: