gmallard / couchbase-beer.rb

Couchbase 2.0 demo application using ruby programming language

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Beer.rb

This application demostrate the how to write rails application using Couchbase 2.0 server.

Installation & Configuration

  1. Install recent Couchbase server 2.0 (beta)

  2. Checkout this application

     git clone git://github.com/couchbaselabs/couchbase-beer.rb.git beer.rb
    
  3. Install all dependencies

     cd beer.rb
     gem install bundler
     bundle install
    
  4. Update config/couchbase.yml if needed, or just inspect its contents

     cat config/couchbase.yml
    
  5. If you are going to use couchbase as rails cache store (by default) you should either create "cache" bucket or fix the appropriate line in config/application.rb. It might be good idea to use memcached type of the bucket for the cache.

  6. Run the application. It will use thin server, you would like to use another one, you should update Gemfile (comment out the thin gem there).

     rails server
    
  7. Navigate to http://localhost:3000

  8. Optionally. If you are going to deploy application using capistrano, you should update config/deploy.rb.

Interesting Points

app/models/
├── beer
│   ├── all
│   │   └── map.js
│   └── by_category
│       ├── map.js
│       └── reduce.js
├── beer.rb
├── brewery
│   ├── all
│   │   └── map.js
│   ├── all_with_beers
│   │   └── map.js
│   ├── by_country
│   │   ├── map.js
│   │   └── reduce.js
│   └── points
│       └── spatial.js
└── brewery.rb

The application use two models: Beer and Brewery. Also it defines views for them, you can find them in corresponding directories app/models/beer and app/models/brewery. You can read more about this directory structure in the README of the couchbase-model ruby gem.

Couchbase as a cache storage: there is another bucket should be configured and mentioned in config/application.rb:68 to replace default cache store in Rails and use Couchbase server instead.

Couchbase as a session storage: just take a look at config/initializers/session_store:10 for further instructions. You probably will need to create yet another bucket for sessions.

About

Couchbase 2.0 demo application using ruby programming language


Languages

Language:Ruby 35.6%Language:JavaScript 28.3%Language:HTML 21.6%Language:CSS 14.4%