Module: Mongoid

Defined in:
lib/mongoid/document.rb,
lib/mongoid.rb,
lib/mongoid/paginator.rb,
lib/mongoid/extensions/array/conversions.rb,
lib/mongoid/extensions/object/conversions.rb,
lib/mongoid/associations/association_factory.rb,
lib/mongoid/associations/has_one_association.rb,
lib/mongoid/associations/has_many_association.rb,
lib/mongoid/associations/belongs_to_association.rb

Overview

:nodoc:

Defined Under Namespace

Modules: Associations, Extensions Classes: ClassNotProvidedError, Document, InvalidAssociationError, NoConnectionError, Paginator, TypeMismatchError

Class Method Summary collapse

Class Method Details

.connect_to(name) ⇒ Object

Connect to the database name supplied. This should be run for initial setup, potentially in a rails initializer.



67
68
69
70
# File 'lib/mongoid.rb', line 67

def self.connect_to(name)
  @@connection ||= Mongo::Connection.new
  @@database ||= @@connection.db(name)
end

.databaseObject

Get the MongoDB database. If initialization via Mongoid.connect_to() has not happened, an exception will occur.

Raises:



74
75
76
77
# File 'lib/mongoid.rb', line 74

def self.database
  raise NoConnectionError unless @@database
  @@database
end