Module: MobilityActiveStorage::Model
- Defined in:
- lib/mobility_active_storage/model.rb,
sig/mobility_active_storage.rbs
Overview
Class macros mixed into ActiveRecord::Base.
Instance Method Summary collapse
-
#has_many_translated_attached(name, fallbacks: false, locales: nil, **attached_options) ⇒ Object
Declares a translated collection of attachments.
-
#has_one_translated_attached(name, fallbacks: false, locales: nil, **attached_options) ⇒ Object
Declares a single translated attachment.
-
#translated_attachment_attribute_names ⇒ Object
Attribute names declared through the attachment macros, including any inherited from a superclass.
Instance Method Details
#has_many_translated_attached(name, fallbacks: false, locales: nil, **attached_options) ⇒ Object
Declares a translated collection of attachments. Options match
#has_one_translated_attached; attached_options is forwarded to has_many_attached.
26 27 28 |
# File 'lib/mobility_active_storage/model.rb', line 26 def has_many_translated_attached(name, fallbacks: false, locales: nil, **) (name, :active_storage_many, fallbacks, locales, ) end |
#has_one_translated_attached(name, fallbacks: false, locales: nil, **attached_options) ⇒ Object
Declares a single translated attachment.
class Product < ApplicationRecord
has_one_translated_attached :document
has_one_translated_attached :manual, fallbacks: true, service: :s3
end
20 21 22 |
# File 'lib/mobility_active_storage/model.rb', line 20 def has_one_translated_attached(name, fallbacks: false, locales: nil, **) (name, :active_storage, fallbacks, locales, ) end |
#translated_attachment_attribute_names ⇒ Object
Attribute names declared through the attachment macros, including any inherited from a superclass. Used to keep attachments out of the hashes Mobility's attribute_methods plugin builds; see AttributeMethodsExclusion.
33 34 35 36 37 38 39 40 |
# File 'lib/mobility_active_storage/model.rb', line 33 def @translated_attachment_attribute_names ||= if superclass.respond_to?(:translated_attachment_attribute_names) superclass..dup else [] end end |