Skip to content

paulcarey/merb_relaxdb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

A plugin for the Merb framework that provides integration with CouchDB via the RelaxDB gem

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages