module Shrine::Plugins::Model::AttacherClassMethods

  1. lib/shrine/plugins/model.rb

Methods

Public Instance

  1. from_model

Public Instance methods

from_model(record, name, **options)

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>
[show source]
   # File lib/shrine/plugins/model.rb
85 def from_model(record, name, **options)
86   attacher = new(**options)
87   attacher.load_model(record, name)
88   attacher
89 end