New to Rails 3? Check out the Ruby on Rails 3 Tutorial book and screencast.

A book and screencast series showing you how to develop and deploy industrial-strength Rails apps in a direct, step by step way. The screencast series includes 12 lessons over more than 15 hours! Get the best "over the shoulder" experience of following what a top Rails 3 developer does when building an app today. Click here to learn more.

Quickly Add CouchDB to Existing Rails Models with Stuffing

In Plugins

Paul Campbell, a partner over at Contrast, has released a new plugin called Stuffing that allows you to add CouchDB functionality to your Rails application's existing ActiveRecord models without you having to quit the world of ActiveRecord (though if you want something that's ActiveRecord-like but CouchDB all the way, check out CouchFoo!)

To use stuffing, just install the Stuffing plugin (instructions here), then use the stuffing directive in your model and you're good to go:

class Post < ActiveRecord::Base

In addition to persisting your model's attributes to CouchDB, Stuffing also lets you create your own attributes for persisting additional attributes to and from CouchDB:

@post = Post.last
@post.stuffing_tags = "rails, plugin, couchdb"
@post.stuffing_tags # => "rails, plugin, couchdb"

Stuffing is great for people who are new to CouchDB but don't want to leave the world of ActiveRecord. It's also great where you might be doing some prototyping on an application and you want to add additional attributes to your models as a test, before committing to writing any tests and code. The Stuffing plugin is available from GitHub.

You might also appreciate this short video introduction to Stuffing that Paul has produced.

This post was written by Matthew Lang, an ERP developer with a keen interest in Ruby and Rails programming.

Post to Twitter Tweet This Post

Vaguely Related Posts (Usually)

3 Comment Responses to “Quickly Add CouchDB to Existing Rails Models with Stuffing”

  1. #1
    Kiran Says:

    Cool! Looking for something similar.

  2. #2
    Paul Campbell Says:

    Thanks for the writeup Matthew. Another Couch only option is: Couch Potato

  3. #3
    Matthew Lang Says:

    Thanks for the link to Couch Potato, Paul!

Leave a Reply