Class: Tenon::TenonContentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/tenon/tenon_content.rb

Class Method Summary collapse

Class Method Details

.add_assoc(klass, content_field) ⇒ Object



23
24
25
26
27
28
# File 'lib/tenon/tenon_content.rb', line 23

def add_assoc(klass, content_field)
  assoc = "#{content_field}_tenon_content_rows".to_sym
  args = [assoc, -> { where(item_method: content_field) }, assoc_opts]
  klass.send(:has_many, *args)
  klass.send(:accepts_nested_attributes_for, assoc, allow_destroy: true)
end