Module: HasManyPurgable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- app/models/concerns/has_many_purgable.rb
Overview
HasManyPurgable
Mark your model with ‘has_many_purgable’ or ‘has_one_purgable’ (both the same thing) to allow any has_many_attached or has_one_attached to be purgable.
Pass ‘has_many_purgable :files, :avatar’ to only allow the files and avatar to be purged.
Works with effective_bootstrap file_field, which renders a Remove button per attachment that submits the attachment’s signed_id in the _purge array.
You must permit the attribute _purge: []
Defined Under Namespace
Modules: Base, ClassMethods
Instance Method Summary collapse
-
#has_many_purgable_names ⇒ Object
All the possible names, merging the actual associations and the given options.
Instance Method Details
#has_many_purgable_names ⇒ Object
All the possible names, merging the actual associations and the given options
54 55 56 57 58 |
# File 'app/models/concerns/has_many_purgable.rb', line 54 def has_many_purgable_names names = .fetch(:names) associations = self.class..keys.map(&:to_sym) names == :all ? associations : (names & associations) end |