Rohit
Rohit

Reputation: 5721

Ruby on Rails -- undo mark_for_destruction

In my rails app the child records get marked_for_destruction I want to undo that action and unmark them. Is there a way?

Thanks in advance.

Upvotes: 12

Views: 2477

Answers (1)

Andrew Ashbacher
Andrew Ashbacher

Reputation: 989

child.reload if child.marked_for_destruction?

From ActiveRecord::AutosaveAssociation:

reload(options = nil)

Reloads the attributes of the object as usual and clears marked_for_destruction flag.

Upvotes: 11

Related Questions