module Para::Ext::ActiveRecord::NestedAttributes
Public Instance Methods
call_reject_if(association_name, attributes)
click to toggle source
Handle rejected nested records that have a fake id, which means that the resource was nevertheless created by Para
during input params parsing. Therefore, we clean those records when they’re rejected.
Calls superclass method
# File lib/para/ext/active_record_nested_attributes.rb, line 16 def call_reject_if(association_name, attributes) super.tap do |rejected| if rejected && attributes['id'].to_s.match(/\A__/) records = association(association_name).target if ::ActiveRecord::Base === records records.destroy elsif (record = records.find { |res| res.id == attributes['id'] }) records.delete(record) end end end end