Module: ActiveStorage::Reflection::ActiveRecordExtensions::ClassMethods

Defined in:
lib/active_storage/reflection.rb

Instance Method Summary collapse

Instance Method Details

#reflect_on_all_attachmentsObject

Returns an array of reflection objects for all the attachments in the class.



49
50
51
# File 'lib/active_storage/reflection.rb', line 49

def reflect_on_all_attachments
  attachment_reflections.values
end

#reflect_on_attachment(attachment) ⇒ Object

Returns the reflection object for the named attachment.

User.reflect_on_attachment(:avatar)
# => the avatar reflection


58
59
60
# File 'lib/active_storage/reflection.rb', line 58

def reflect_on_attachment(attachment)
  attachment_reflections[attachment.to_s]
end