Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 250
Rohit Avatar asked Feb 22 '11 15:02

Rohit


1 Answers

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.

like image 56
Andrew Ashbacher Avatar answered Oct 27 '22 06:10

Andrew Ashbacher