Cells for Rails 2.3 is out!
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!
June 29th, 2009 at 9:53 pm
Does Cells support adding additional models in cells? I need to create modular system consisting of cells that can load own data from tables.
July 2nd, 2009 at 8:44 am
hey garus,
what you asked for is a way to package cells and models for distribution between different rails apps- that’s what engines are for. they are included in rails 2.3 core.
the directory layout of your plugin would be
vendor/plugins/your-plugin/app/models
vendor/plugins/your-plugin/app/cells
September 4th, 2009 at 7:22 am
[...] bekomme ich Nick dazu, dass er Cells und Apotomo hier selbst vorstellt, sonst muss ich das übernehmen. (@Nick: “Du weisst ja wie das endet, [...]