Module: Para::Ext::ActiveRecord::NestedAttributesClassMethods
- Defined in:
- lib/para/ext/active_record_nested_attributes.rb
Constant Summary collapse
- PARA_REJECT_ALL_BLANK_PROC =
Override default :reject_all proc to handle fake ids as empty keys, avoiding the model to be created with only its fake id.
proc { |attributes| attributes.all? { |key, value| (key == 'id' && value.to_s.match(/\A__/)) || key == '_destroy' || value.blank? } }
Instance Method Summary collapse
-
#accepts_nested_attributes_for(*attr_names) ⇒ Object
Intercept the ‘reject_if: :all_blank` option to also consider fake ids as blank fields and avoid empty params assignation.
Instance Method Details
#accepts_nested_attributes_for(*attr_names) ⇒ Object
Intercept the ‘reject_if: :all_blank` option to also consider fake ids as blank fields and avoid empty params assignation
43 44 45 46 47 |
# File 'lib/para/ext/active_record_nested_attributes.rb', line 43 def accepts_nested_attributes_for(*attr_names) = attr_names. [:reject_if] = PARA_REJECT_ALL_BLANK_PROC if [:reject_if] == :all_blank super(*attr_names, ) end |