Module: Shrine::Plugins::Model::AttacherClassMethods
- Defined in:
- lib/shrine/plugins/model.rb
Instance Method Summary collapse
-
#from_model(record, name) ⇒ Object
Initializes itself from a model instance and attachment name.
Instance Method Details
#from_model(record, name) ⇒ Object
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>
85 86 87 88 89 |
# File 'lib/shrine/plugins/model.rb', line 85 def from_model(record, name, **) attacher = new(**) attacher.load_model(record, name) attacher end |