couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Campbell <p...@rushedsunlight.com>
Subject Stuffing: a Ruby on Rails plugin to add CouchDB to existing ActiveRecord models
Date Mon, 09 Feb 2009 02:21:04 GMT
Hi all,

I've been very quiet around these parts, but I've noticed that there
are plenty of users on here that use Ruby/Rails. I've been working on
some CMS stuff backed with CouchDB and decided to do some abstracting
so that I could get my blog up and running off CouchDB. I thought you
might be interested in this:

http://www.pabcas.com/feeling/stuffing-couchdb-into-rails

Basically, it's a plugin that lets you use CouchDB with existing (or
new) ActiveRecord SQL models. You basically don't ever have to leave
ActiveRecord or SQL, but you get a bonus attribute (your 'stuffing')
that is a hash that persists to CouchDB.

In brief, it's something like this:

class Post < ActiveRecord::Base
  stuffing
end

@post = Post.new
@post.stuffing
=> {}
@post.stuffing_title = "Welcome to Stuffing"
@post.stuffing
=> {:title => "Welcome to Stuffing"}
@post.stuffing_title
=> "Welcome to Stuffing"

It's pretty basic stuff, but it's a really quick win if you want to
use CouchDB on top of existing ActiveRecord models, or if you want to
use the schema-less nature of CouchDB for your documents, but use
ActiveRecord finders, plugins and relationships.

The plugin itself is on Github where there's more examples and options etc.

http://github.com/paulca/stuffing/tree/master

Let me know if you think this is useful, or if you have any questions
about the motivations that led to writing this,

Paul

Mime
View raw message