Module: CompositeContent::ActiveRecord::ClassMethods
- Defined in:
- lib/composite_content/active_record.rb
Overview
Integration methods with ActiveRecord models These methods are available on any ActiveRecord model once CompositeContent is loaded.
rubocop:disable Naming/PredicateName, Rails/ReflectionClassName
Instance Method Summary collapse
Instance Method Details
#has_composite_content(name = :composite_content, types: []) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/composite_content/active_record.rb', line 12 def has_composite_content(name = :composite_content, types: []) CompositeContent::Model::Builder::Block.build(self, name, types) slot_class = CompositeContent::Model::Builder::Slot.build(self, name, types) has_one name, class_name: slot_class.name, as: :parent, dependent: :destroy accepts_nested_attributes_for name, reject_if: :all_blank include Mixins.instance_mixin(name) extend Mixins.class_mixin(name) end |