Module: DuckRecord::NestedAttributes

Extended by:
ActiveSupport::Concern
Included in:
Base
Defined in:
lib/duck_record/nested_attributes.rb

Overview

:nodoc:

Defined Under Namespace

Modules: ClassMethods Classes: TooManyRecords

Instance Method Summary collapse

Instance Method Details

#_destroyObject

Returns ActiveRecord::AutosaveAssociation::marked_for_destruction? It’s used in conjunction with fields_for to build a form element for the destruction of this association.

See ActionView::Helpers::FormHelper::fields_for for more info.



387
388
389
# File 'lib/duck_record/nested_attributes.rb', line 387

def _destroy
  marked_for_destruction?
end

#mark_for_destructionObject

Marks this record to be destroyed as part of the parent’s save transaction. This does not actually destroy the record instantly, rather child record will be destroyed when parent.save is called.

Only useful if the :autosave option on the parent is enabled for this associated model.



371
372
373
# File 'lib/duck_record/nested_attributes.rb', line 371

def mark_for_destruction
  @marked_for_destruction = true
end

#marked_for_destruction?Boolean

Returns whether or not this record will be destroyed as part of the parent’s save transaction.

Only useful if the :autosave option on the parent is enabled for this associated model.

Returns:

  • (Boolean)


378
379
380
# File 'lib/duck_record/nested_attributes.rb', line 378

def marked_for_destruction?
  @marked_for_destruction
end