Skip to content

Instantly share code, notes, and snippets.

@scarfacedeb
Created February 11, 2015 19:27
Show Gist options
  • Save scarfacedeb/f0822a8448eecb21efe0 to your computer and use it in GitHub Desktop.
Save scarfacedeb/f0822a8448eecb21efe0 to your computer and use it in GitHub Desktop.
Trick to make activerecord-import work with refile
brands = []
brand = Brand.new
brand.name = "Harry's"
brand.remote_logo_url = "http://example.com/image.png" # store file in cache and give it an ID
brand.logo_attacher.store! # force refile to fill logo_id attribute without .save
brands << brand
# Bulk import all of the brands at once. NO CALLBACKS!
Brand.import brands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment