Archive for March, 2009

Cells for Rails 2.3 is out!

Saturday, March 28th, 2009

Cells bring back components to Rails, as superfast mini-controllers plugged into views or actions.

Just in time with the Rails 2.3 release cells got tagged 2.3 compatible. Thanks to some (great!) major changes in the Rails API we were able to throw away a LOT lines of code, configuration and thus make cells faster, cleaner and even easier to use. Here’s a short overview.

Built-in Engines support Engines are now an official part of the Rails core - meaning we can put cells inside engines/plugins and use them in our application as if they would reside in the global app/ directory. Even better:

No more configuration The tiresome task of configuring Rails working with cells is obsolete. You don’t have to touch config/environment.rb anymore. Especially you no longer need the lines

require File.join(File.dirname(__FILE__), '../vendor/plugins/cells/boot')

I18N support Use translation features in your cell views like the t("...") helper to provide localized versions of your application.

Automatic template lookup caching Cell template lookups (the filepaths of templates) are now cached like controller view lookups, providing automatic reloading in development mode and caching in production by using rails’ ActionView::Paths.

State output caching You can apply fine-grained output caching for each cell state. As soon as you declare a state as cached in the cell class, it won’t be executed the next time you render it. To re-render you can define a devalidation proc.

cache :some_state
cache :some_state,  Proc.new {|cell| false if cell.too_old?}

Download cells

Grab the plugin at github and also check out the example app demonstrating how to plug cells into your app and how to use advanced features like caching states and localized cell views.

Major refactorings in Rails 2.3 provide some clever new hooks for plugins. We loved hitting the delete key, getting rid of cells code and having a better cells as a result. Thanks and props to the rails core team!