CouchRestAdapter

This is a realy early version.

This project rocks and uses MIT-LICENSE.

Requirements

  • Rails > 4

  • Couchrest

  • Requires config/database.yml file

Instalation

In Gemfile

gem 'couch_rest_adapter'

Sample config/database.yml

defaults: &defaults
  host: localhost
  port: 5984
  protocol: http

development:
  <<: *defaults
  name: db

test:
  <<: *defaults
  name: db_test

CouchViews

In order for “‘Model.all“` to workyou need to add a view like (code in cs), named ’all’:

(d) ->
  split_id = d._id.split('/')
  t = split_id[0]
  emit t, d

For ‘Model.find_by_attr’ to work, you will need this view named like ‘by_attribute’:

(doc) ->
  type = doc._id.split('/')[0]
  for a of doc
    emit([type, a, doc[a]], doc._id)

We are planning to add a rake task that setup this view on install.

Model Declaration

class User < CouchRestAdpater::Base
  use_default_database
end

TODO

  • Allow setting new attributes with “‘model.attribute = value“`

  • More test coverage

  • Add tasks for pushing design documents

  • Add support for basic database http auth.