parm530
4/4/2018 - 4:03 PM

AR Callback Methods

Callback methods to help your objects

ActiveRecord Callbacks

  • Way to insert yourself in the process of crreating updating and deleting a record.
  • Examples include:
CREATE                  UPDATE                  DESTROY
before_validation       before_validation

-------------------------VALIDATION------------------------------

after_validation        after_validation

before_save             before_save
before_create           before_update           before_destroy

-------------------------DATABASE INTERACTION---------------------

after_create            after_update            before_destroy
after_save              after_save            
  • Used in your model classes! Ex: before_save :private_method_name, must be written in the private section of your code!