module Shrine::Plugins::Model::AttacherClassMethods

Public Instance Methods

from_model(record, name, **options) click to toggle source

Initializes itself from a model instance and attachment name.

photo.image_data #=> "{...}" # a file is attached

attacher = Attacher.from_model(photo, :image)
attacher.file #=> #<Shrine::UploadedFile>
# File lib/shrine/plugins/model.rb, line 85
def from_model(record, name, **options)
  attacher = new(**options)
  attacher.load_model(record, name)
  attacher
end