0.01
No commit activity in last 3 years
No release in over 3 years
Merb plugin that provides integration with CouchDB
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Runtime

>= 1.0
 Project Readme

Overview

merb_relaxdb is a merb plugin that provides integration with CouchDB via the RelaxDB gem. Version numbers indicate compatibility with Merb. Revision numbers are excluded e.g. merb_relaxdb 1.0 should be compatible with Merb 1.0.x

The current release includes integration with merb-auth, but this should not yet be considered stable. A sample integration file is included below.

merb_relaxdb expects your merb app to augment the standard layout as described in the following tree.
couchdb.yml is mandatory. Reference data, sample data and views are optional.
merb-gen model my_model will create a sample couchdb.yml.

To use merb_relaxdb, list dependency "merb_relaxdb", "1.0" in config/dependencies.rb and use_orm :relaxdb in config/init.rb

For more details on using RelaxDB, see the RelaxDB wiki


my_merb_app $ tree . |— Rakefile |— app |— autotest |— config | |— couchdb.yml |— couchdb | |— data | | |— reference | | | `— reference_data.rb | | `— sample | | `— sample_data.rb | `— views | `— views.js |— lib |— log |— public |— scratch `— spec


Sample merb/merb-auth/setup.rb


begin
  Merb::Authentication.user_class = User 
  
  # Mixin the salted user mixin  
  require 'merb-auth-more/mixins/salted_user'
  require 'merb_relaxdb/rdb_salted_user'
  
  Merb::Authentication.user_class.class_eval{ include Merb::Authentication::Mixins::SaltedUser }
      
  # Setup the session serialization
  class Merb::Authentication

    def fetch_user(session_user_id)
      RelaxDB.load(session_user_id) rescue nil
    end

    def store_user(user)
      user.nil? ? user : user._id
    end
  end
  
rescue => e
  Merb.logger.error <<-TEXT
  
    You need to setup some kind of user class with merb-auth.  
    Merb::Authentication.user_class = User
    
    If you want to fully customize your authentication you should use merb-core directly.  
    
    See lib/authentication/setup.rb and strategies.rb to customize your setup

    TEXT
end