Skip to content

Instantly share code, notes, and snippets.

@timanglade
Created March 25, 2011 19:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timanglade/887514 to your computer and use it in GitHub Desktop.
Save timanglade/887514 to your computer and use it in GitHub Desktop.
require 'couchrest_model'
module RcmEngine
class Organization < CouchRest::Model::Base
use_database CouchRest.database('http://<LOGIN>:<PASSWORD>@<ACCOUNT>.cloudant.com/rcm_engine_remix_rcm/')
property :description, String
property :name, String
property :remix_organization, Integer
property :subdomains, [String] #These will be used to hook up to the
view_by :subdomain, :map => "
function(doc) {
if ((doc['couchrest-type'] == 'RcmEngine::Organization') && (doc['subdomains']!=null)) {
for(var idx in doc.subdomains) {
emit(doc.subdomains[idx], doc);
}
}
}"
def self.get_for_subdomain(subdomain)
organization = Organization.find_by_subdomain(subdomain)
organization
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment