Install

Rid is available as RubyGem:

$ gem install rid
You can also download, clone or fork from GitHub: http://github.com/jo/rid

Generate

Getting started via

$ rid generate app blog
This will generate a scaffold directory structure at ./blog.

Contribute

You're welcome!

Rid needs your help. Rid is in an early stage but wants to grew up fast.

If you are like-minded, do not hesitate to fork Rid and contribute.

Get rid of SQL

Have you ever felt about database normalization as jailing data?

CouchDB is a document-oriented database. That means it holds your data in a schema-free space. CouchDB can be queried and indexed in a MapReduce fashion using JavaScript.

Turn off the scale oneway

Ever tried scaling an SQL database? Ever worked on replication? If so, CouchDB will appear like an angel. It is designed from base for replication. Replication means scaling. With CouchDB you can address petabytes of data and tons of concurrent requests using simple strategies.

Read more about Scaling CouchDB, Clustering and Load Balancing in the open book CouchDB: The Definitive Guide by J. Chris Anderson, Jan Lehnardt and Noah Slater.

Deployment as it should be

With standalone CouchDB applications deployment is getting as your desire: easy. CouchApp code is written in CouchDB design documents. That are special documents prefixed with _design. That means your code can be pushed as easy as your data.

Install Rid

Lets describe how Rid can be installed.

Installation of Ruby

Rid is written in Ruby. So you need a Ruby environment. On Debian like Linux distrubutions you can install Ruby and friends via apt:

# apt-get install ruby rake rubygems
If you're developing on Mac OS X, all prerequisites are met.
For other platforms, refer to the Ruby website.

Install Rid

Rid is shipped as a RubyGem. Therefore the installation of Rid is as easy as typing three words:

$ gem install rid

The rid command

Now you have read about Rid until here you might be interested and its time to take a tour on how development feels with Rid.

Getting help

Now its time for the truth:

$ rid
This should give you an introduction of what you can do with Rid:
Usage: rid COMMAND [ARGS]

The most common rid commands are:
 generate    Generate new code (short-cut alias: "g")
 push        Push application code to Couchdb
 pull        Pull latest application code from Couchdb
 routes      List application urls

In addition to those, there are:
 destroy      Undo code generated with "generate"

All commands can be run with -h for more information.
        
For every command is more help available. So, lets see how Rid can generate code for you:
$ rid generate -h
Usage: rid generate GENERATOR [args] [options]

General options:
  -h, [--help]     # Print generators options and usage
  -p, [--pretend]  # Run but do not make any changes
  -f, [--force]    # Overwrite files that already exist
  -s, [--skip]     # Skip files that already exist
  -q, [--quiet]    # Supress status output

Please choose a generator below:

application  # The 'application' generator creates a new Rid application
list         # The 'list' generator creates a scaffold list function
scaffold     # The 'scaffold' generator creates a scaffold skelet
show         # The 'show' generator creates a scaffold show function
update       # The 'update' generator creates a scaffold update function
validation   # The 'validation' generator creates a validation function
view         # The 'view' generator creates a scaffold view function
        

Lets take Rid command line help further and see what the application generator does and how it is invoked.

$ rid generate application -h
Usage:
  rid generate|destroy application APP_PATH [options]

Options:
  -G, [--skip-git]  # Skip Git ignores and keeps

Runtime options:
  -s, [--skip]     # Skip files that already exist
  -f, [--force]    # Overwrite files that already exist
  -p, [--pretend]  # Run but do not make any changes
  -q, [--quiet]    # Supress status output

Description:
    The 'application' generator creates a new Rid application
    with a default directory structure and configuration
    at the path you specify.

Example:
    rid generate application ~/rid/weblog

    This generates a skeletal Rid installation in ~/rid/weblog.
    See the README in the newly created application to get going.
        

Lets go!

We're going on and start making our hands dirty. In this section I will show you how to build a simple scaffold application.
The application will give us the common CRUD interface: Creating Posts, showing posts and listing posts, deleting Posts and editing Posts.
Posts are super simple documents with an ID, a title and a body.

Generate the application

$ rid generate application blog
      create  
      create  .ridrc
      create  README
      create  .gitignore
      create  _id
      create  validate_doc_update.js
      create  lists
      create  shows
      create  updates
      create  views
      create  _attachments
      create  _attachments/images
      create  _attachments/javascripts
      create  _attachments/stylesheets
      create  _attachments/stylesheets/application.css
      create  _attachments/index.html
      create  lib
      create  lib/mustache.js
      create  lib/path.js
      create  lib/templates
      create  lib/templates/layout.mustache

Generate code

Now we create the Post scaffold. Remember that each post should have a title as well as a body.
The ID is included automatically.

Inside your newly created ./blog directory run:

$ rid generate scaffold post title body
      create  views/posts
      create  views/posts/map.js
      inject  validate_doc_update.js
      create  lists/posts.js
      create  lib/templates/posts/index.mustache
      create  shows/post.js
      create  lib/templates/posts/show.mustache
      create  lib/templates/posts/form.mustache
      create  lib/templates/posts/delete.mustache
      create  lib/templates/posts/deleted.mustache
        

Push it to your local server

We have created a scaffold application and we are ready to push it to our server.
By default, Rid selected your local server at http://127.0.0.1:5984 and uses the database blog, as we named our application blog. You can change this by editing the .ridrc file.

OK, lets push it:

$ rid push
Created database http://127.0.0.1:5984/blog
Pushing to http://127.0.0.1:5984/blog/_design/blog
Pushed 1-2014518f027b1d74337b5158a5fba3d2
        

Lets see how we can access our blog:

$ rid routes
Static
  index: http://127.0.0.1:5984/blog/_design/blog/index.html
Post
  show:  http://127.0.0.1:5984/blog/_design/blog/_show/post/:id
  list:  http://127.0.0.1:5984/blog/_design/blog/_list/posts/posts
        
Point your browser to http://127.0.0.1:5984/blog/_design/blog/_list/posts/posts and enjoy!

Whats next

You see, those routes are sweet but not as nice as you propably would like to. The next CouchDB release 0.11 will come with a flexible routing mechanism. Read more about it at the Couchio blog.
Next releases of Rid will of course help you setting up wunderful routes.