Class: ActiveRecord::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/models/nested_attributes.rb

Class Method Summary collapse

Class Method Details

.accepts_nested_attributes_for_with_inheritance_management(*attr_names) ⇒ Object



7
8
9
10
# File 'lib/models/nested_attributes.rb', line 7

def accepts_nested_attributes_for_with_inheritance_management(*attr_names)
  accepts_nested_attributes_for_without_inheritance_management(*attr_names)
  alert_subclasses_of_new_nested_attributes
end

.alert_subclasses_of_new_nested_attributesObject



13
14
15
16
17
# File 'lib/models/nested_attributes.rb', line 13

def alert_subclasses_of_new_nested_attributes
  subclasses.each do |subclass|
    subclass.superclass_received_nested_attributes(nested_attributes_options)
  end
end

.superclass_received_nested_attributes(super_nested_attr_options) ⇒ Object



19
20
21
22
23
# File 'lib/models/nested_attributes.rb', line 19

def superclass_received_nested_attributes(super_nested_attr_options)
  nested_attributes_options.update(super_nested_attr_options) do |hash, oldval, newval|
    oldval.nil? ? newval : oldval
  end
end