ActiveRecord callbacks are an easy way to run code during the different stages of your model’s life.
For example, say you have a Q&A site, and you want to be able to search through all the questions. Every time you make a change to a question, you’ll want to index it in something like ElasticSearch. Indexing takes a while and isn’t urgent, so you’ll do it in the background with Sidekiq.
This seems like the perfect time to use an after_save callback! So in your model, you’ll write something li...
Published on March 22, 2015 16:00