Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

ActiveRecord Observers - RORLab Season 3-6


Published on

Published in: Technology
  • Be the first to comment

ActiveRecord Observers - RORLab Season 3-6

  1. 1. Active RecordObserversRor lab. season 3- the 6th round -May 11, 2013ChangHoon Jeong(@seapy)
  2. 2. Contents• The Object Life Cycle• Validations Overview• Validation Helpers• CommonValidationOptions• ConditionalValidation• CustomValidations• Working withValidationErrors• DisplayingValidation Errorsin theView• Callbacks Overview• Available Callbacks• Running Callbacks• Skipping Callbacks• Halting Execution• Relational Callbacks• Conditional Callbacks• Callback Classes• Observers• Transaction CallbacksValidations Callbacks
  3. 3. Callback Classes• To reuse callback methods for other modelsas an instance methoda model objectinstancemethod
  4. 4. Callback Classesas a class method
  5. 5. Observers• Similar to callbacks• for the callbacks with the code that isn’tdirectly related the model• without changing the code of the model• ex. sending confirmation email after userregistration
  6. 6. Creating Observers
  7. 7. Registering Observers• config/application.rb• or config/environments
  8. 8. Sharing Observersas a model name
  9. 9. TransactionCallbacks• after_commit or after_rollback
  10. 10. 감사합니다.
  11. 11.