Skip to content

Instantly share code, notes, and snippets.

@renchap
Created August 31, 2016 11:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renchap/ca16dd38c59196b9f55d012741a46443 to your computer and use it in GitHub Desktop.
Save renchap/ca16dd38c59196b9f55d012741a46443 to your computer and use it in GitHub Desktop.
shrine_concatenation
class ImageParts << ActiveRecord::Base
include PartUploader[:file]
belongs_to :image
end
class Image << ActiveRecord::Base
include ImageUploader[:file]
has_many :image_parts
[...]
def create_file_from_parts!
file.create_from_concatenation image_parts.map(&:file), name: "#{id}.jpg"
save!
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment