Rails Plugins
When I come across a problem in Rails that I know I’ll see again, I usually extract the solution out into a plugin. Here’s a list of all the plugins I’ve come up with so far. The big, complicated ones have their own pages. The simple ones, well… they’re simple.
Plugins for You!
content_cache
Cache rendered views within the context of your layout, allowing you to mix dynamic content with cached static content.
dollars_and_cents
Stores prices as integers in your database, but access them as floats.
dynamic_session_exp
Allows you to configure Rails to serve up session cookies with expiration dates relative to the current time, instead of some fixed date in the future.
http_caching
Allows your Rails application to take advantage of the caching mechanisms built into HTTP 1.1 (i.e., 304 Not Modified return code). Inspired by a Rails cookbook entry (manuals.rubyonrails.com/read/chapter/62).
rails_environments
Simple methods for determining which environment Rails is running.
rails_rcov
Find your tests’ blind spots easily with Mauricio Fernandez’s rcov code coverage tool and this set of dynamic Rake tasks.
responsible_markup
A series of assertions for use in Rails functional tests which allow you to check for valid markup, unobtrusive Javascript, and other hallmarks of web professionalism.
simple_http_auth
A quick, clean way of adding HTTP authorization to your Rails application. No need for complicated backends, gigantic user models, or other unneeded complexity. Just you, a password prompt, and whether or not someone should be allowed in.
usps_countries
Replaces the Rails countries list with a list of countries to which the United States Postal Service can send mail. (If you’re concerned not with accurately representing people’s geographic self-identification, but rather where in the hell they want a package sent, this is for you.)
xhtml_content_type
xhtml_content_type allows you to set the default MIME type for rendered .rhtml views to application/xhtml+xml if the client supports it, and only falling back to text/html for older clients.
Upcoming Plugins
I’ve got some tricks up my sleeve as well!
- Logger Dump
- Smart Search
All of my Rails plugins are © 2006 Coda Hale, but released under the MIT License.