For instructions on upgrading to newer versions, visit mongoid.org.
-
Mongoid now contains eager loading in the form of
Criteria#includes(*args)
. This works on has_one, has_many, belongs_to associations and requires the identity map to be enabled in order to function. Setidentity_map_enabled: true
in yourmongoid.yml
. Ex:Person.where(title: "Sir").includes(:posts, :game)
-
Relations can now take a module as a value to the
:extend
option. (Roman Shterenzon) -
Capped collections can be created by passing the options to the
#store_in
macro:Person.store_in :people, capped: true, max: 1000000
-
Mongoid::Collection now supports
collection.find_and_modify
-
Document#has_attribute?
now aliases toDocument#attribute_present?
-
#930 You can now turn off the Mongoid logger via the mongoid.yml by doing
logger: false
-
#909 We now raise a
Mongoid::Errors::Callback
exception if persisting with a bang method and a callback returns false, instead of the uninformative validations error from before.
-
#1173 has_many relations no longer delete all documents on a set of the relation (= [ doc_one, doc_two ]) but look to the dependent option to determine what behaviour should occur. :delete and :destroy will behave as before, :nullify and no option specified will both nullify the old documents without deleting.
-
#1142, #767 Embedded relations no longer immediately persist atomically when accessed via a parent attributes set. This includes nested attributes setting and
attributes=
orwrite_attributes
. The child changes then remain dirty and atomically update when save is called on them or the parent document.
-
#1190 Fixed the gemspec errors due to changing README and CHANGELOG to markdown.
-
#1180, #1084, #955 Mongoid now checks the field types rather than if the name contains
/id/
when trying to convert to object ids on criteria. -
#1176 Enumerable targets should always return the in memory documents first, when calling
#first
-
#1175 Make sure both sides of many to many relations are in sync during a create.
-
#1172 Referenced enumerable relations now properly handle
#to_json
(Daniel Doubrovkine) -
#1040 Increased performance of class load times by removing all delegate calls to self.class.
-
#1159 Fixed build blocks not to cancel out each other when nested.
-
#1154 Don't delete many-to-many documents on empty array set.
-
#1153 Retain parent document reference in after callbacks.
-
#1151 Fix associated validation infinite loop on self referencing documents.
-
#1150 Validates associated on
belongs_to
isfalse
by default. -
#1149 Fixed metadata setting on
belongs_to
relations. -
#1145 Metadata inverse should return
nil
ifinverse_of
was set asnil
. -
#1139 Enumerable targets now quack like arrays.
-
#1136 Setting
belongs_to
parent tonil
no longer deletes the parent. -
#1120 Don't call
in_memory
on relations if they don't respond to it. -
#1075 Set
self
in default procs to the document instance. -
#1072 Writing attributes for nested documents can take a hash or array of hashes.
-
#990 Embedded documents can use a single
embedded_in
with multiple parent definitions.
-
#1148 Fixed
respond_to?
on all relations to return properly. -
#1146 Added back the Mongoid destructive fields check when defining fields.
-
#1141 Fixed conversions of
nil
values in criteria. -
#1131 Verified Mongoid/Kaminari paginating correctly.
-
#1105 Fixed atomic update consumer to be scoped to class.
-
#1075
self
in default lambdas and procs now references the document instance. -
#740 Removed
embedded_object_id
configuration parameter. -
#661 Fixed metadata caching on embedded documents.
-
#595 Fixed relation reload flagging.
-
#410 Moving documents from one relation to another now works as expected.
This was a specific release to fix MRI 1.8.7 breakages introduced by 2.1.6.
-
#1126 Fix setting of relations with other relation proxies.
-
#1122 Hash and array fields now properly flag as dirty on access and change.
-
#656 Fixed reload breaking relations on unsetting of already loaded associations.
-
#647 Prefer
#unset
to#remove_attribute
for removing values. -
#290 Verify pushes into deeply embedded documents.
-
#1116 Embedded children retain reference to parent in destroy callbacks.
-
#1110, #1115 Don't memoize metadata related helpers on documents.
-
#1112
db:create_indexes
no longer indexes subclasses multiple times. -
#1111, #1098 Don't set
_id
in$set
operations. -
#1007 Update attribute properly tracks array changes.
This was a specific release to get a Psych generated gemspec so no more parse errors would occur on those rubies that were using the new YAML parser.
-
#1109 Fixed validations not loading one to ones into memory.
-
#1107 Mongoid no longer wants required
mongoid/railtie
inapplication.rb
. -
#1102 Fixed nested attributes deletion.
-
#1097 Reload now runs
after_initialize
callbacks. -
#1079 Embeds many no longer duplicates documents.
-
#1078 Fixed array criteria matching on embedded documents.
-
#1028 Implement scoped on one-to-many and many-to-many relations.
-
#988 Many-to-many clear no longer deletes the child documents.
-
#977 Autosaving relations works also through nested attributes.
-
#972 Recursive embedding now handles namespacing on generated names.
-
#943 Don't override
Document#attributes
. -
#893 Verify count is not caching on many to many relations.
-
#815 Verify
after_initialize
is run in the correct place. -
#793 Verify
any_of
scopes chain properly with any other scope. -
#776 Fixed mongoid case quality when dealing with subclasses.
-
#747 Fixed complex criteria using its keys to render its string value.
-
#721
#safely
now properly raises validation errors when they occur.
-
#1082 Alias
size
andlength
tocount
on criteria. (Adam Greene) -
#1044 When multiple relations are defined for the same class, always return the default inverse first if
inverse_of
is not defined. -
#710 Nested attributes accept both
id
and_id
in hashes or arrays. -
#1047 Ignore
nil
values passed toembeds_man
pushes and substitution. (Derick Bailey)
-
#1021, #719 Many to many relations dont trigger extra database queries when pushing new documents.
-
#607 Calling
create
on large associations does not load the entire relation. -
#1064
Mongoid::Paranoia
should respectunscoped
andscoped
. -
#1026
model#update_attribute
now can update booleans tofalse
. -
#618 Crack XML library breaks Mongoid by adding
#attributes
method to theString
class. (Stephen McGinty)
-
Mongoid now requires MongoDB 1.8.x in order to properly support the
#bit
and#rename
atomic operations. -
Traditional slave support has been removed from Mongoid. Replica sets should be used in place of traditional master and slave setups.
-
Custom field serialization has changed. Please see serializable for changes.
-
The dirty attribute tracking has been switched to use ActiveModel, this brings many bug fixes and changes:
-
#756 After callbacks and observers see what was changed instead of changes just made being in previous_changes
-
#434 Documents now are flagged as dirty when brand new or the state on instantiation differs from the database state. This is consistent with ActiveRecord.
-
#323 Mongoid now supports [field]_will_change! from ActiveModel::Dirty
-
-
Mongoid model preloading in development mode now defaults to
false
. -
:autosave => true
on relational associations now saves on update as well as create. -
Mongoid now has an identity map for simple
find_by_id
queries. See the website for documentation.
-
#1067 Fields now accept a
:versioned
attribute to be able to disable what fields are versioned withMongoid::Versioning
. (Jim Benton) -
#587 Added order preference to many and many to many associations. (Gregory Man)
-
Added ability to chain
order_by
statements. (Gregory Man) -
#961 Allow arbitrary
Mongo::Connection
options to pass throughMongoid::Config::Database
object. (Morgan Nelson) -
Enable
autosave
for many to many references. (Dave Krupinski) -
The following explicit atomic operations have been added:
Model#bit
,Model#pop
,Model#pull
,Model#push_all
,Model#rename
,Model#unset
. -
Added exception translations for Hindi. (Sukeerthi Adiga)
-
#974 Fix
attribute_present?
to work correctly then attribute value isfalse
, thanks to @nickhoffman. (Gregory Man) -
#960 create indexes rake task is not recognizing a lot of mongoid models because it has problems guessing their model names from filenames. (Tobias Schlottke)
-
#874 Deleting from a M-M reference is one-sided. (nickhoffman, davekrupinski)
-
Replace deprecated
class_inheritable_hash
dropped in Rails 3.1+. (Konstantin Shabanov) -
Fix inconsistent state when replacing an entire many to many relation.
-
Don't clobber inheritable attributes when adding subclass field inheritance. (Dave Krupinski)
-
#914 Querying embedded documents with
$or
selector. (Max Golovnia) -
#514 Fix marshaling of documents with relation extensions. (Chris Griego)
-
Metadata#extension
now returns aModule
, instead of aProc
, when an extension is defined. -
#837 When
allow_dynamic_fields
is set tofalse
and loading an embedded document with an unrecognized field, an exception is raised. -
#963 Initializing array of embedded documents via hash regressed (Chris Griego, Morgan Nelson)
-
Mongoid::Config.reset
resets the options to their default values. -
Mongoid::Fields.defaults
is memoized for faster instantiation of models.