Created
February 11, 2015 19:27
-
-
Save scarfacedeb/f0822a8448eecb21efe0 to your computer and use it in GitHub Desktop.
Trick to make activerecord-import work with refile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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