Module: Mongoid

Defined in:
lib/mongoid/field.rb,
lib/mongoid.rb,
lib/mongoid/commands.rb,
lib/mongoid/criteria.rb,
lib/mongoid/document.rb,
lib/mongoid/attributes.rb,
lib/mongoid/timestamps.rb,
lib/mongoid/associations.rb,
lib/mongoid/commands/save.rb,
lib/mongoid/commands/create.rb,
lib/mongoid/commands/delete.rb,
lib/mongoid/commands/destroy.rb,
lib/mongoid/commands/delete_all.rb,
lib/mongoid/associations/factory.rb,
lib/mongoid/commands/destroy_all.rb,
lib/mongoid/associations/decorator.rb,
lib/mongoid/extensions/hash/accessors.rb,
lib/mongoid/extensions/date/conversions.rb,
lib/mongoid/extensions/time/conversions.rb,
lib/mongoid/extensions/array/conversions.rb,
lib/mongoid/extensions/float/conversions.rb,
lib/mongoid/extensions/object/conversions.rb,
lib/mongoid/extensions/string/conversions.rb,
lib/mongoid/extensions/string/inflections.rb,
lib/mongoid/extensions/symbol/inflections.rb,
lib/mongoid/extensions/array/parentization.rb,
lib/mongoid/extensions/boolean/conversions.rb,
lib/mongoid/extensions/integer/conversions.rb,
lib/mongoid/extensions/object/parentization.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, Attributes, Commands, Extensions, Timestamps Classes: Criteria, Document, Field, InvalidAssociationError, NoConnectionError, TypeMismatchError, ValidationsError

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.



63
64
65
66
# File 'lib/mongoid.rb', line 63

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:



70
71
72
73
# File 'lib/mongoid.rb', line 70

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