Hey y’all,
I’ve worked up a simple Rails components plugin, originally based on
Nick and Peter’s Cells plugin. Features include:
- encapsulation: All data must come from method arguments or database
records - there is no access to the session, the request, or params.
Encapsulation FTW! - inheritable views: Pretty much awesome for plugins. If I were re-
writing ActiveScaffold these days, I’d make it a base component and
have all the child scaffolds inherit. - argument-based caching: Flip a switch to turn on caching for a
method, and set up TTL- or version-based expiration (better be using
memcache!).
My goal is to keep this plugin clean and simple and compatible with
good RESTful design. It’s been tested with Rails 2.0, and I expect it
to be compatible with Rails 2.1 since I’ve already dealt with the
TemplateFinder and caching changes.
I’ll be at RailsConf08 if anyone wants to meet up and talk about
components in Rails.
The standard links:
*
http://codelevy.com/articles/2008/05/14/rails-components-revisited-new-components-plugin
- http://codelevy.com/articles/2008/05/23/components-get-caching
- GitHub - cainlevy/components: Rails components with inheritable views, caching, and good encapsulation.
-Lance