# After\_save deletes is an exception is raised?

**URL:** <https://www.ruby-forum.com/t/after-save-deletes-is-an-exception-is-raised/98756>\
**Category:** Rails\
**Created:** [July 18, 2006, 12:05am UTC](https://www.ruby-forum.com/t/after-save-deletes-is-an-exception-is-raised/98756 "2006-07-18T00:05:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [July 18, 2006, 12:05am UTC](https://www.ruby-forum.com/t/after-save-deletes-is-an-exception-is-raised/98756/1 "2006-07-18T00:05:33Z")

</div>

Does after\_save in a model delete if an exception is raised in there?

I simply did

def after\_save  
raise ‘hmmm’  
end

and it raised the exception but there was nothing in the database. I  
removed that entire method and its in the database. Is this correct?

Thank You,  
Ben J.  
E: removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [July 18, 2006, 12:18am UTC](https://www.ruby-forum.com/t/after-save-deletes-is-an-exception-is-raised/98756/2 "2006-07-18T00:18:34Z")

</div>

On Jul 17, 2006, at 3:04 PM, Ben J. wrote:

> Does after\_save in a model delete if an exception is raised in there?

Look for BEGIN … ROLLBACK in your logs. That’s the save transaction  
rolling back due to the exception in after\_save. It’s as if your  
record was never created.

jeremy

---

<div class="post-metadata">

**Author:** ![benjohnson](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/3ec8ea/32.png) [@benjohnson](https://www.ruby-forum.com/u/benjohnson)\
**Post date:** [July 18, 2006, 12:54am UTC](https://www.ruby-forum.com/t/after-save-deletes-is-an-exception-is-raised/98756/3 "2006-07-18T00:54:49Z")

</div>

So it the row locked or something until after\_save is completed?  
Because I am calling methods in after\_save that do things with that  
new row addition. These other methods are saying that it doesn’t  
exist, because the other methods are doing Model.find the\_id.

Thanks for your help.

Thank You,  
Ben J.  
E: removed\_email\_address@domain.invalid
