Module: ErpTechSvcs::Extensions::ActiveRecord::HasFileAssets::ClassMethods
- Defined in:
- lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb
Overview
If set to auto destroy any files related to a model via this mixin will automatically be removed regardless of any other relationships they have. It defaults to true since most files should be removed when the model is removed.
Instance Method Summary collapse
Instance Method Details
#has_file_assets(auto_destroy = true) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/erp_tech_svcs/extensions/active_record/has_file_assets.rb', line 14 def has_file_assets(auto_destroy=true) extend HasFileAssets::SingletonMethods include HasFileAssets::InstanceMethods if auto_destroy before_destroy :destroy_all_files end has_many :file_asset_holders, :as => :file_asset_holder, :dependent => :destroy has_many :files, :through => :file_asset_holders, :class_name => 'FileAsset', :source => :file_asset, :include => :capabilities end |