Sha256: cbd544a17ad0298c46274bf6c31f720d5696075762a6adacb25121e29ee376ab
Contents?: true
Size: 964 Bytes
Versions: 116
Compression:
Stored size: 964 Bytes
Contents
module Lalala::ExtActiveRecord::Assets extend ActiveSupport::Concern module ClassMethods def has_many_assets(name, options={}) class_name = options.delete(:class_name) class_name ||= if name.to_s.include?("image") then "::ImageAsset" else "::FileAsset" end attr_accessible :"#{name}_attributes" has_many name, class_name: class_name, as: :asset_owner, dependent: :destroy, conditions: { asset_owner_section: name.to_s } accepts_nested_attributes_for name, allow_destroy: true end def has_one_asset(name, options={}) class_name = options.delete(:class_name) class_name ||= if name.to_s.include?("image") then "::ImageAsset" else "::FileAsset" end attr_accessible :"#{name}_attributes" has_one name, class_name: class_name, as: :asset_owner, dependent: :destroy, conditions: { asset_owner_section: name.to_s } accepts_nested_attributes_for name, allow_destroy: true end end end
Version data entries
116 entries across 116 versions & 1 rubygems