Intridea Blog: Technology, Design, Business

Back to Blog

Get in Touch

You're currently viewing posts tagged with: "activesupport"

Define Custom Callbacks for ActiveRecord and More

By Jerry Cheung | March 22, 2012 ActiveRecord, callbacks, activesupport

Rails ActiveRecord models have a lifecycle that developers are allowed to hook into. But while most of us know about before_save and after_update, there are a few lesser unknown callbacks that are good to know about before you reinvent them. In this post, I'll cover all of the available ActiveRecord lifecycle callbacks, and also show how you can define custom callbacks for normal ruby objects.

Read more…

Writing a Custom Rails Cache Store

By Jerry Cheung | March 6, 2012 rails, performance, caching, activesupport
Medium

When you use Rails built-in helpers for page, action, and fragment caching, the cached data is stored into an instance of ActiveSupport::Cache::Store. But while the interface for using the cache stores are the same, each cache store implementation has different performance characteristics and are suited for different jobs. In this post, I'll cover what cache stores are available with Rails by default, how to tune them, and how to write your own custom cache store.

Read more…