Callbacks.

This is a good reference for Active record callbacks.

[link to callbacks][1]
[1]: http://api.rubyonrails.org/classes/ActiveRecord/Callbacks.html