Skip to content

Instantly share code, notes, and snippets.

@mankind
Created May 20, 2011 01:27
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 mankind/982172 to your computer and use it in GitHub Desktop.
Save mankind/982172 to your computer and use it in GitHub Desktop.
creating a new collection per new account
#creating a new collection called based on name supplied
def self.create_tenant(name)
@connection = Mongo::Connection.new
@db = @connection.db("#{name}")
@coll = @db.collection("#{name}")
end
#creating a new account should automatically create collection
def self.create_account(name)
create_tenant(name)
account = Account.create([
account.new( :name=> "#{name}", :subdomain => ' ')
])
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment