Upgrade to Pro — share decks privately, control downloads, hide ads and more …

ActiveRecord Observers - RORLab Season 3-6

ActiveRecord Observers - RORLab Season 3-6

seapy

May 11, 2013
Tweet

More Decks by seapy

Other Decks in Programming

Transcript

  1. Active Record Observers Ror lab. season 3 - the 6th

    round - May 11, 2013 ChangHoon Jeong(@seapy)
  2. Contents • The Object Life Cycle • Validations Overview •

    Validation Helpers • Common Validation Options • Conditional Validation • Custom Validations • Working with Validation Errors • Displaying Validation Errors in the View • Callbacks Overview • Available Callbacks • Running Callbacks • Skipping Callbacks • Halting Execution • Relational Callbacks • Conditional Callbacks • Callback Classes • Observers • Transaction Callbacks Validations Callbacks
  3. Callback Classes • To reuse callback methods for other models

    as an instance method a model object instance method
  4. Observers • Similar to callbacks • for the callbacks with

    the code that isn’t directly related the model • without changing the code of the model • ex. sending confirmation email after user registration