How are observers and callbacks different from each other?



How are observers and callbacks different from each other?..

Answer / Ashok Kumar Yadav

In Ruby on Rails, Observers are classes that observe Active Record models and respond to specific events (e.g., before_save or after_create). Callbacks, on the other hand, are methods defined within a model that are called automatically during certain events in the life cycle of the object (e.g., `before_save` callback method within a model). Observers can be used to perform tasks across multiple models, while callbacks are specific to one model.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Ruby on Rails Interview Questions

what is Rails Migration?

1 Answers  


how you can run Rails application without creating databases?

1 Answers  


Who designed active record in rails?

1 Answers  


How is the model view controller framework used in ruby on rails?

1 Answers  


Are there any disadvantages of ruby on rails? If yes, mention them.

1 Answers  


Explain the advantages of ruby on rails?

1 Answers  


What is the main difference between procs and blocks?

1 Answers  


Tell me what is orm (object-relationship-model) in rails?

1 Answers  


Do you know what is “yield” in ruby on rails?

1 Answers  


what are the limits of Ruby on Rails?

1 Answers  


Please explain what are the positive aspects of rails?

1 Answers  


What is the difference between false and nil in ruby?

1 Answers  


Categories