Overview
For instructions on upgrading to newer versions, visit mongoid.org.
As of version 5.0.2, please refer to the github releases for change logs.
5.0.1
Resolved Issues
- MONGOID-3020 Test added to show it's no longer an issue.
- MONGOID-3025 Test added to show it's no longer an issue.
- MONGOID-3061 No longer an issue.
- MONGOID-3073 Test added to show it's no longer an issue.
- MONGOID-3085 Test added to show it's no longer an issue.
- MONGOID-3101 No longer an issue.
- MONGOID-3160 No longer an issue.
- MONGOID-3176 No longer an issue.
- MONGOID-3214 Test added to show it's no longer an issue.
- MONGOID-3296 Add update callback for counter_cache.
- MONGOID-3326 Test added to show it's no longer an issue.
- MONGOID-3361 No longer an issue.
- MONGOID-3365 Test added to show it's no longer an issue.
- MONGOID-3402 Apply persistence options to parent.
- MONGOID-3524 No longer an issue.
- MONGOID-3529 Test exists already showing it's not an issue.
- MONGOID-3543 Test exists already showing it's not an issue.
- MONGOID-3611 Test added to show it's no longer an issue.
- MONGOID-3650 No longer an issue.
- MONGOID-3826](https://jira.mongodb.org/browse/MONGOID-3826), [MONGOID-4109 Fix Timelessness leaks.
- MONGOID-3946 Test added to show it's no longer an issue.
- MONGOID-3969 Test added to show it's no longer an issue.
- MONGOID-3971 Not an issue.
- MONGOID-3979 Not an issue, tests exist already.
- MONGOID-3985 Not an issue.
- MONGOID-4078 Behavior is intended.
- MONGOID-4079 Not an issue.
- MONGOID-4088 Account for sub-document dot notation with
#pluckresults. - MONGOID-4098 Fixed by a change to the Ruby driver. See RUBY-1029.
- MONGOID-4101 Not an issue.
- MONGOID-4106 Not an issue.
- MONGOID-4110 Not an issue.
- MONGOID-4119 Ensure that criteria selector becomes pipeline operator value.
- MONGOID-4121 Not an issue.
- MONGOID-4123 Fixed as a result of MONGOID-4159.
- MONGOID-4125 Make sure none scopes referenced in procs are applied.
- MONGOID-4132 Not an issue.
- MONGOID-4157 Fixed by version 2.1.2 of the Ruby driver.
- MONGOID-4162 Adapt index option mappings to new driver. (@Nielsomat)
- MONGOID-3737 Test added to show it's no longer an issue.
- MONGOID-3621 Not an issue.
- MONGOID-3551 Not an issue.
- MONGOID-3696 Test added to show it's no longer an issue.
- MONGOID-3858 Test added to show it's no longer an issue.
- MONGOID-3672 Not an issue.
- MONGOID-4172 Use positional operator only on 1 level deep nesting.
- Added public cert to repo and sign gem if private key is present
5.0.0
Major Changes (Backwards Incompatible)
-
Mongoidnow uses the official Mongo Ruby Driver 2.x instead of Moped. -
Most driver specific configuration options have changed, please see here for the new options.
-
All references to
sessionare now replaced withclient. This includes the mongoid.yml configuration,store_inoptions, and all exceptions and modules withSessionin the name. -
find_and_modifyhas been removed and replaced with 3 options:find_one_and_update,find_one_and_deleteandfind_one_and_replace. -
text_searchhas been removed as it is now a$textoption in a query from 2.6 on. -
Mongoidno longer supports MongoDB 2.2 - support is now for only 2.4 and higher. -
#3768firstandlastno longer add an_idsort when no sorting options have been provided. In order to guarantee that a document is the first or last, it needs to now contain an explicit sort. -
Document#deleted?alias has been removed, please continue to useDocument#destroyed?.
New Features
-
#4016Allow private and protected setters on fields for atomic operations. (Rob Smith) -
#3985Return nil when using{upsert: true}infind_and_modify(Adrien Siami) -
#3963Allow extended JSON object ids to be passed tofind. -
#3846Allow#pluckwhen none is used in criteria. (Braulio Martinez)
Resolved Issues
-
#4091Use subclass context when calling a scope defined in a superclass. (Edgars Beigarts) -
#4075Made remove index logging specific to each index that was actually getting removed. -
#4071Fixed loading of enumerable relation to check the added documents when iterating. -
#4077Many relations now include Enumerable. -
#4052Fixed uniqueness validation on localized fields with no value. -
#4033Removed all uses of the $ positional operator in atomic updates. -
#4030Dup/clone exceptions auto-include dynamic attributes. -
#4005Fixed inclusion of mongoid withRailscomponents that don't have theRailsenvironment. -
#3993Fixes issue wheredup/clonefails for embedded documents that use store_as without using::Mongoid::Attributes::Dynamic -
#3991Fixed embedded documents not flagging as changed after calling#changed?and modifying the child elements. -
#3874Adding snapshot option to context. -
#3868Loading models in rake tasks now expands the rails path. -
#3764Fixed case statement check for enumerable targets. -
#3740FixesMissing attribute: '_id'error when using methods only or without (dx7) -
#3631Fixes issue wherebefore_savecallback can get called twice after a child create -
#3599Fixed application of default scopes from superclass in subclasses. -
#3104Fixed enumerable targets to check first/last in proper order.
4.0.2
New Features
-
#3931Add#find_or_create_by!method to many associations. (Tom Beynon) -
#3731Add find_by! method. (Guillermo Iguaran)
Resolved Issues
-
#3722Use the right database name when combining#store_inand#with. (Arthur Neves) -
#3934Dont apply sort when doing a find_by. (Arthur Neves) -
#3935fix multiple fields sorting on contextual memory. (chamnap) -
#3904BSON::Document#symbolize_keysshould return keys as symbols. (Arthur Neves) -
#3948Fix remove_undefined_indexes on rails 4.2, to symbolize right the Document keys. (Adam Wróbel) -
#3626Document#to_key, needs to return a ObjectId asStringso we can query back using that id. (Arthur Neves) -
#3888raise UnknownAttributeError when 'set' is called on non existing field and::Mongoid::Attributes::Dynamicis not included in model. (Shweta Kale) -
#3889'set' will allow to set value of non existing field when::Mongoid::Attributes::Dynamicis included in model. (Shweta Kale) -
#3812Fixed validation context when saving (Yaroslav Zemlyanuhin)
4.0.1
Resolved Issues
-
#3911Fix relations named "parent". (nkriege) -
#3792/\#3881 Fix many internal calls to#_idinstead of#idto avoid issues when overloading #id (Gauthier Delacroix) -
#3847Fix 'QueryCache#get_more' result, when collection has more documents than first query batch. (Angelica Korsun) -
#3684Dont raise MissingAttributeError, when using a only() scope. (Arthur Neves) -
#3703pluck method should not compact the values. (Arthur Neves) -
#3773Use nanoseconds for cache_key timestamp instead of plain seconds. (Máximo Mussini)
4.0.0
Major Changes (Backwards Incompatible)
-
#3320Remove Rails dependencies on database rake tasks. (Arthur Neves)All db:* rake tasks should work as before when using Rails. When not in a Rails, just load the database tasks using: load 'mongoid/tasks/database.rake' -
Mongoid4 now only supports MongoDB 2.4.0 and higher. -
Document#metadatahas been renamed toDocument#relation_metadatato avoid common conflicts. Relation proxies also have this renamed to the same as well. -
Scopes and default scopes must now all be defined within lambdas or procs.
-
skip_version_checkconfig option was removed. -
IdentityMap removed. (Arthur Neves)
-
Eager load rework. Eager load now doesnt need the identity map to load related documents. A set of preloaders can eager load the associations passed to .includes method. (Arthur Neves)
-
Mongoidnow supports the new read preferences that the core drivers provide. These include:- `:primary`: Will always read from a primary node. (default) - `:primary_preferred`: Attempt a primary first, then secondary if none available. - `:secondary`: Will always read from a secondary node. - `:secondary_preferred`: Attempt a secondary first, then primary if none available. - `:nearest`: Attempt to read from the node with the lowest latency. Sample syntax: Person.with(read: :secondary).first The `:consistency` option is no longer valid, use the `:read` option now. -
Mongoidnow defaults all writes to propagate (formerly "safe mode") and now has different propagate semantics:- `{ w: -1 }`: Don't verify writes and raise no network errors. - `{ w: 0 }`: Don't verify writes and raise network errors. - `{ w: 1 }`: Verify writes on the primary node. (default) - `{ w: n }`: Verify writes on n number of nodes. - `{ w: "majority" }`: Verify writes on a majority of nodes. Sample syntax: Person.with(write: {w: :majority}).create!(name: "John") The `:safe` option is no longer valid use the `:write` option now. -
#3230ArrayandHashfields now validate that the correct types are getting set, instead of allowing any value. (Rodrigo Saito) -
#3043/\#2949 Rework on the internals of persistence options. (Arthur Neves) -
Mongoidnow requires Active Model 4 or higher. -
Document#setnow accepts multiple attributes in the form of a hash, instead of the previous(field, value)args. Field aliases and typecasting are also now supported in this operation.document.set(name: "Photek", likes: 10000) -
Document#renamenow accepts multiple attributes in the form of a hash, instead of the previous(field, value)args. Field aliases are supported.document.rename(first_name: "fn", last_name: "ln") -
Document#incnow accepts multiple attributes in the form of a hash, instead of previously only being able to increment one value at a time. Aliases and serialization is supported.document.inc(score: 10, place: -1, lives: -10) -
Document#popnow accepts multiple attributes in the form of a hash, instead of previously only being able to pop one value at a time. Aliases and serialization is supported.document.pop(names: 1, aliases: -1) -
Document#bitnow accepts multiple attributes in the form of a hash, instead of previously only being able to apply one set of operations at a time. Aliases and serialization are supported.document.bit(age: { and: 13 }, score: { or: 13 }) -
Document#pullnow accepts multiple attributes in the form of a hash, instead of previously only being able to pull one value at a time. Aliases and serialization is supported.document.pull(names: "James", aliases: "007") -
Document#pull_allnow accepts multiple attributes in the form of a hash, instead of previously only being able to pull one value at a time. Aliases and serialization is supported.document.pull_all(names: ["James", "Bond"], aliases: ["007"]) -
Document#push_allhas been removed since it was deprecated in MongoDB 2.4. UseDocument.pushinstead. -
Document#pushnow accepts multiple attributes in the form of a hash, and can handle the pushing of single values or multiple values to the field via $push with $each. Aliases and serialization is supported.document.push(names: "James", aliases: [ "007", "Jim" ]) -
Document#add_to_setnow accepts multiple attributes in the form of a hash, and now aliases and serialization are supported.document.add_to_set(names: "James", aliases: "007") -
Criteria atomic operations API is now changed to match the changes in the single document atomic API, for example:
Band.where(name: "Depeche Mode").inc(likes: 10, followers: 20) -
#3399#createand#create!on relations can now take an array of attributes as the first parameter to create multiple documents at once.person.addresses.create([{ street: "Bond" }, { street: "Upper" }]) person.addresses.create!([{ street: "Bond" }, { street: "Upper" }]) -
#3141rake db:test:preparenow sets up all defined indexes ifMongoidis the only ODM/ORM in the environment. -
#3138update_attributescan now be accessed simply by callingupdate. -
#3083A new rake task:rake db:mongoid:remove_undefined_indexeshas been added to remove indexes from the database that are not explicitly defined in the models. (Aidan Feldman) -
#3029Therelation_fieldfield that is added for a single use case with polymorphic relations has been removed. So where the following would work before:class Eye include Mongoid::Document belongs_to :eyeable, polymorphic: true end class Face include Mongoid::Document has_one :left_eye, class_name: "Eye", as: :eyeable has_one :right_eye, class_name: "Eye", as: :eyeable end This would now need to be modeled as (with the appropriate migration): class Eye include Mongoid::Document belongs_to :left_socket, class_name: "Face", inverse_of: :left_eye belongs_to :right_socket, class_name: "Face", inverse_of: :right_eye end class Face include Mongoid::Document has_one :left_eye, class_name: "Eye", inverse_of: :left_socket has_one :right_eye, class_name: "Eye", inverse_of: :right_socket end -
#3075update_attributenow properly calls the setter method instead of usingwrite_attribute. -
#3060Allow atomically blocks to allow multiple calls of the same type. (Brian Norton) -
#3037Model indexes are no longer stored in anindex_optionshash on the model class. Instead, an array namedindex_specificationsnow exists on the class which contains a list ofIndexable::Specificationobjects. This is so we could properly handle the case of indexes with the same keys but different order. -
#2956Caching on queries now only happens whencacheis specifically called. (Arthur Neves) -
#2659Mongoid::Railtienow properly uses only one initializer and the name has changed tomongoid.load-config. -
#2656rake db:reseedis nowrake db:reset(Arthur Neves) -
#2648Booleanbecomes::Mongoid::Booleanto avoid polluting the global namespace with a commonly used class by other libraries. -
#2603Return values from setters are now always the set value, regardless of calling the setter or using send. -
#2597Mongoid::Observerwas removed in line withRails4. -
#2563Theallow_dynamic_fieldsconfiguration option has been removed as dynamic fields are now allowed on a per-model level. In order to allow a model to use dynamic fields, simply include the module in each. (Josh Martin)class Band include Mongoid::Document include Mongoid::Attributes::Dynamic end -
#2497Callingto_jsonno longer tampers with the return value from the driver, and proper returns{ "$oid" : object_id.to_s }instead of just the string representation previously. -
#2433Mongoid::Paranoiahas been removed. -
#2432Mongoid::Versioninghas been removed. -
#2218Creating or instantiating documents that have default scopes will now apply the default scope to the document, if the scope is not complex. -
#2200Mass assignment security now mirrorsRails4's behavior.without_protectionoption was also removed.attr_accessibleclass method was removed. Mongoid and Strong parameters should work fine for mass assignment protection. -
delete_allanddestroy_allno longer take a:conditionshash but just the raw attributes. -
#1908Documents now loaded from criteria using#onlyor#withoutwill now raise an error when attempting to save, update, or delete these records. Additionally fields excluded from the fields retrieved from the database will also raise an exception when trying to access them. -
#1344Atomic updates can now be executed in anatomicallyblock, which will delay any atomic updates on the document the block was called on until the block is complete.Update calls can be executed as normal in the block: document.atomically do document.inc(likes: 10) document.bit(members: { and: 10 }) document.set(name: "Photek") end The document is also yielded to the block: document.atomically do |doc| doc.inc(likes: 10) doc.bit(members: { and: 10 }) doc.set(name: "Photek") end The atomic commands are have a fluid interface: document.atomically do |doc| doc.inc(likes: 10).bit(members: { and: 10 }).set(name: "Photek") end If the fluid interface is leveraged without the `atomically` block, the operations will persist in individual calls. For example, the following would hit the database 3 times without the block provided: doc.inc(likes: 10).bit(members: { and: 10 }).set(name: "Photek") The block is only good for 1 document at a time, so and root document updates cannot be mixed at this time.
New Features
-
Mongoidnow usesActiveSupport::LogSubscriberto subscribe logs, and ActiveSupport::Notifications to send operation logs. (Arthur Neves) Example of log subscription:ActiveSupport::Notifications.subscribe('query.moped') do |event| .. end -
Field types can now use symbols as well as class names. See: https://github.com/mongoid/mongoid/blob/master/lib/mongoid/fields.rb#L16 for the available mappings.
-
#3580Fields can now be reset to their default values, with the methods:document.reset_name_to_default! -
#3513Documents now have a#destroy!method that will raise aMongoid::Errors::DocumentNotDestroyederror if a destroy callback returns a false value. -
#3496Added class level and criteria levelfind_or_create_by!. -
#3479Map/reduce now respects criteria no timeout options if output is not inline. -
#3478Criteria objects now have a#nonemethod that will cause the criteria to never hit the database and always have zero documents.Band.none Band.none.where(name: "Tool") # Always has zero documents. -
#3410Mongoidnow has a query cache that can be used as a middleware in Rack applications. (Arthur Neves)For Rails: config.middleware.use(Mongoid::QueryCache::Middleware) -
#3319Counters can now be reset from a document instance:document.reset_counters(:relation) -
#3310embedded_in relations now accept atouchoption to update parents. -
#3302Aliasing usingalias_attributenow properly handles aliases in criteria. -
#3155Rangefield will persist the exclude_end when provided. (Daniel Libanori) -
#3146Adding:overwritefield option, when it`s true, it wont check duplicates. (Daniel Libanori) -
#3002Reloading theRailsconsole will also now clear Mongoid's identity map. -
#2938A configuration optionduplicate_fields_exceptionhas been added that when set totruewill raise an exception when defining a field that will override an existing method. (Arthur Neves) -
#2924MongoDB 2.4 beta text search now has a DSL provided byMongoid. Like other queries, text searches are lazy evaluated, and available off the class or criteria level.Note that any 3rd party gem that provides a `text_search` method will now no longer work with Mongoid, and will need to change its syntax. Examples: Band.text_search("mode").project(name: 1).each do |doc| # ... end Band.limit(10).text_search("phase").language("latin") Band.where(:likes.gt => 1000).text_search("lucy") -
#2855Multiple extensions can now be supplied to relations. (Daniel Libanori)
Resolved Issues
-
#3676Make pluck work with embedded associations (Arthur Neves) -
#2898Dirty attribute methods now properly handle field aliases. (Niels Ganser) -
#3620Add ActiveModel module instance methods to prohibited_methods list. (Arthur Neves) -
#3610Don't allow atomic operations on read-only attributes (Frederico Araujo) -
#3619Don't validate documents that are flagged for destruction. (Christopher J. Bottaro) -
#3617Don't skip index creation on cyclic documents. (shaiker) -
#3568Fixed missing attributes error on present localized fields. -
#3514Fixed query cache to work on first/last calls. -
#3383/\#3495 Fix has_and_belongs_to_many eager load. (Arthur Neves) -
#3492$rename operations should not mongoize values. (Vladislav Melanitskiy) -
#3490Allow localized fields to work with booleanfalsevalues. -
#3487Map Boolean to::Mongoid::Booleanin field definitions. (Arthur Neves) -
#3449Touch needs to work for create and update. (Greggory Rothmeier) -
#3347Creating documents off of scopes for embedded relations now properly sets the parent document on the created children. -
#3432Fixed mongoization ofDateTimelosing precision. -
#3397Fixed $ne matcher for embedded documents to match server behavior. -
#3352Allow named scopes named "open" to work through 1-n relations. -
#3348Fixing compounded indexes having the same keys with different directions. (Arthur Neves) -
#2701Fixing extra query on belongs_to binding. (Arthur Neves) -
#3089Allow demongoization of strings to floats (Daniel Libanori) -
#3278Counter cache should update the document in memory too. (Arthur Neves) -
#3242Has_many relation must use the inverse foreign_key. (Arthur Neves) -
#3233Don't double call validation callbacks when cascading children and relation validation is turned on. -
#3197Improvements in the calls toaggregateson root and embedded collections. (Wojciech Piekutowski) -
#3144/\#3219 Fixing name collision on @_children ivar. (Arthur Neves) -
#3088Rangefield can accept a hash, which could be the attribute from the db. (Daniel Libanori) -
#3116Relations instance variables are now all prefixed with_. -
#3093Only flatten 1 level when atomically pushing arrays. -
#3063Document#becomesnow properly sets base object on errors. (Adam Ross Cohen) -
#3019Atomic operations will no longer attempt to persist if the document is not persisted. -
#2903Removed unused stringto_aextension.
3.1.7
Resolved Issues
-
#3465Fixed ambiguous relation errors where inverse_of is set to nil. -
#3414Backport skip and limit options on aggregation. (Wojciech Piekutowski) -
#3469Fix RegexpError: failed to allocate memory: /./ on.hash_dot_syntax?(Dmitry Krasnoukhov)
3.1.6
Resolved Issues
-
#3337Ensure localized fields map is cloned with inheritance. -
#3262Fixed atomic array operations on HABTM foreign key fields from turning single elements into arrays. -
#3282Fixed.timelessoption to use a thread local instead of a class attribute. Also remove the timeless methods from all docs, and only add to timestamps docs. (Arthur Neves)
3.1.5
Resolved Issues
-
#3231Allow evolution of proxy documents to work in criteria. -
#3247Bump dependency on tzinfo to 0.3.29. -
#3203Fixedindex: truespecification for polymorphic relations. -
#3192Fixed aliased fields + localized fields combinations with validation. (Johnny Shields) -
#3173Fixed issues around many to many relations with custom primary keys. (Bowen Sun) -
#3159Upserting now properly flags documents as persisted. -
#3137Allow multiplebelongs_tosets in a row with ids. -
#3079Embedded docs with paranoia parents were losing the _id when reloading from db, as they didnt have the right persisted? value. (Arthur Neves) -
#3081Criteria'smethod_missingnow checks if an array responds to the provided method before calling entries in order to not hit the database if aNoMethodErrorwas to get raised. -
#3068Fixed spec runs on non standard MongoDB ports ifMONGOID_SPEC_PORTis set. -
#3047Ensureblank?andempty?don't fall through method missing on criteria. -
Include updated_at on cache_key even when is a short timestamp (Arthur Neves)
3.1.4
Resolved Issues
-
#3044Ensure enumerable targets match arrays in case statements. -
#3034first_or_createon criterion now properly passes the block to create instead of calling after the document was created. -
#3021Removedmongoid.ymlwarning from initializer, this is now handled by the session configuration options. -
#3018Uniqueness validator now properly serializes values in its check. (Jerry Clinesmith) -
#3011Fixed aliased field support for uniqueness validation. (Johnny Shields) -
#3008Fixed subclasses not being able to inherit scopes properly when scope is added post class load. (Mike Dillon) -
#2991Document.timelessnow properly scopes to the instance and not thread. -
#2980Dynamic fields now properly handle in place editing of hashes and arrays. (Matthew Widmann) -
#2979pluckno longer modifies the context in place. (Brian Goff) -
#2970Fixed counter cache to properly use the name of the relation if available then the inverse class name second if not. -
#2959Nested attributes will now respectautosave: falseif defined on the relation. -
#2944Fixed uniqueness validation for localized fields when case insensitive is true. (Vladimir Zhukov)
3.1.3
Resolved Issues
-
Dont duplicate embedded documents when saving after calling becomes method. (Arthur Neves)
-
#2961Reloading a mongoid.yml configuration now properly clears previously configured sessions. -
#2937Counts can now take atrueargument to factor in skip and limit. (Arthur Neves) -
#2921Don't use type in identity map selection if inheritance is not in play. (Arthur Neves) -
#2893Removed memoization of collection name and database name so lambdas withstore_inwork properly when changing. -
#2911The_destroyattribute on 1-n relations when processing nested attributes can now be a string or symbol when passed an array. -
#2886Fixed namespacing issue withRailsgenerators. -
#2885Fixed touch for aliased fields. (Niels Ganser) -
#2883Allow cyclic relations to not raise mixed relation errors. -
#2867plucknow properly handles aliased fields. -
#2862Autosaving no longer performs extra unnecessary queries. (Arthur Neves)
3.1.2
Resolved Issues
-
#2851Fixed BigDecimal demongoization of NaN values. (nkem) -
#2848Fixedtouchto work when usinng short timestamps. (Arthur Neves) -
#2840Fixed end-to-endno_timeoutoption handling. -
#2826Dynamic fields are now properly mongoized. -
#2822Marshal load of relations now properly reapplies extensions.
3.1.1
Resolved Issues
-
#2839Validations fixed to use the type cast value with the exception of the numericality validator. (Lailson Bandeira) -
#2838store_inoptions now properly merge instead of override. (Colin MacKenzie)
3.1.0
New Features
-
The minimum MongoDB requirement is now raised to 2.2, since we now depend on the aggregation framework.
-
The minimum Active Model and Active Support dependencies have been raised to 3.2.
-
#2809Relations can now specify a primary key to use instead of the id on foreign keys.class Person include Mongoid::Document field :username, type: String has_many :cats, primary_key: "username" end class Cat include Mongoid::Document belongs_to :person, primary_key: "username" end -
#2804$geoNear support has now been added to criteria.Bar.where(:likes.gt => 1000).geo_near([ 52, 13 ]) Bar.geo_near([ 52, 13 ]).max_distance(0.5).spherical -
#2799Criteria#mapcan now accept a symbol of a field name as well as a block to perform a more optimizedmap. (Gosha Arinich)Band.where(:likes.gt => 1000).map(:name) -
#2798Aggregations (sum,min,max,avg) now use the aggregation framework instead of map/reduce. (Gosha Arinich) -
#2776MongoDB 2.4.x new index types are now supported: "2dsphere", "text", and "hashed". (Irakli Janiashvili) -
#2767$maxScan support from Origin is now supported. (Jonathan Hyman) -
#2701Cleanup up extra excessive database queries with 1-1 relations. -
#2693Custom collection names can be passed to the model generator. (Subhash Bhushan)rails g model band --collection=artists -
#2688Model.createandModel.create!now can take an array of attributes hashes to create multiple documents at once. If an array of attributes is provided then an array of documents is returned.Band.create([{ name: "Tool" }, { name: "Placebo" }]) Band.create!([{ name: "Tool" }, { name: "Placebo" }]) -
#2670Unsetting fields now accepts multiple fields instead of only 1. (Arthur Neves)band.unset(:name, :founded) Band.where(name: "Placebo").unset(:members, :origin) -
#2669Passing a block toCriteria#newnow properly sends the block through to the model's constructor. (Arthur Neves) -
#2667exists?no longer hits the database in cases where we have the necessary information in memory. -
#2665Mongoidnow supports a counter cache forbelongs_torelations. (Arthur Neves)class Band include Mongoid::Document belongs_to :label, counter_cache: "b_count" end class Album include Mongoid::Document belongs_to :band, counter_cache: true end -
#2662Embedded documents that havebelongs_torelations may now eager load them. -
#2657Logger getter and setter convenience methods have been added to theConfigmodule. (Arthur Neves) -
#2615Index options can now take a specific database name if the indexes are only to exist in a database other than the default.class Band include Mongoid::Document index name: 1, { database: "another_db" } end -
#2613Procs can now be provided as values tostore_in:class Band include Mongoid::Document store_in database: ->{ Thread.current[:database] } end -
#2609Pass through batch_size option to query. (Martin Mauch) -
#2555Passing hashes tofindwhen the documents id is of type hash now properly works. (Szymon Kurcab) -
#2545The$positional operator is used for update selectors on embedded documents that are nested 1 level deep, when appropriate. -
#2539Mongoid.modelsnow tracks all models in the application for more accurate determination of models for things such as indexing rake tasks. (Ara Howard) -
#2525Added the ability to have short timestamped fields with aliases. This sets timestamp fields asc_atandu_atthat are also aliased ascreated_atandupdated_atfor convenience. (Rodrigo Saito)class Band include Mongoid::Document include Mongoid::Timestamps::Short # For c_at and u_at. end class Band include Mongoid::Document include Mongoid::Timestamps::Created::Short # For c_at only. end class Band include Mongoid::Document include Mongoid::Timestamps::Updated::Short # For u_at only. end -
#2465Documents now have anattribute_before_type_castfor proper handling of validations. (Gerad Suyderhoud) -
#2443expire_after_secondsis now a valid index option (https://www.mongodb.com/docs/manual/core/indexes/#ttl-indexes, https://www.mongodb.com/docs/manual/tutorial/expire-data/).class Event include Mongoid::Document field :created_at, type: DateTime index({ created_at: 1 }, { expire_after_seconds: 3600 }) end -
#2373Relations with thetouch: trueoption will now be automatically touched when the child document is created or destroyed. -
Added
Document.first_or_create!andCriteria#first_or_create!. This raises a validations error if creation fails validation.Band.where(name: "Depeche Mode").first_or_create! Band.where(name: "Tool").first_or_create!(active: true) -
Added
Document.first_or_initializeandCriteria#first_or_initialize. This is the same asfirst_or_createbut initializes a new (unpersisted) document if none is found.Band.where(name: "Depeche Mode").first_or_initialize Band.where(name: "Tool").first_or_initialize(active: true) -
Added
Model.pluckandCriteria#plucksimilar to Active Record's, which returns an array of values for the provided field. (Jason Lee)Band.where(name: "Depeche Mode").pluck(:_id) Band.where(name: "Tool").pluck(:likes) -
#2324Embeds many relations now properly handledelete_if. -
#2317AddedDocument.first_or_createandCriteria#first_or_create. This will return the first matching document or create one with additional attributes if one does not exist. (incorvia)Band.where(name: "Depeche Mode").first_or_create Band.where(name: "Tool").first_or_create(active: true) -
#2292AddedModel.each_with_index. -
#2285Config.load_configurationis now public for those who want to instantiate settings directly from a hash. -
#2275Added rake taskdb:mongoid:purgethat will drop all collections with the exception of the system collections in the default database. -
#2257after_findcallbacks have been added for when documents are returned from the database.class Band include Mongoid::Document after_find do |doc| # Some logic here. end end -
#2223Allow to find documents by javascript with parameters that are protected from javascript injection viaModel.for_js.Band.for_js("this.name = param", param: "Tool") Band.where(:likes.gt => 1000).for_js("this.likes < this.follows") -
#2197When providing session configuration with no ports,Mongoidwill now default these to 27017. -
#21801-n and n-n relations now support before/after add/remove callbacks. (Rodrigo Saito)class Band include Mongoid::Document :albums, after_add: :notify_labels has_many :followers, before_remove: ->(band, follower){ notify_unfollow(follower) } end -
#2157Criteria#updateandCriteria#update_allnow serialize values according to their field type, if a field is defined. -
#2022Custom callbacks can now register themselves for use with observers by using theobservablemacro.class Band include Mongoid::Document define_model_callbacks :notification observable :notification end class BandObserver < Mongoid::Observer def before_notification(band) #... end def after_notification(band) #... end end -
#1766Many to many relations will not touch the database if the foreign key is an empty array. -
#1564Many to many foreign keys now have the default set lazily only if the relation has been accessed. This avoids storing empty arrays if the relation has not been touched.
Resolved Issues
-
#2730Calling sort on a context properly updates the context's criteria. (Arthur Neves) -
#2719distinctis now available at the class level.Band.distinct(:name) -
#2714Overriding sessions when the new session has a different database will now properly switch the database at runtime as well. -
#2697Eager loading fixed when including multiple models that inherit from the same class. (Kirill Lazarev) -
#2664In memory sorting of embedded documents now properly works when multiple fields are provided. (Neer Friedman)
3.0.24
Resolved Issues
#2879remove_attributeon new documents no longer creates an unnecessary $unset operation.
3.0.23
Resolved Issues
-
#2851Fixed BigDecimal demongoization of NaN values. (nkem) -
#2841Callingdelete_allordestroy_allon an embeds many when in the middle of a parent update will now properly execute the deletion. (Arthur Neves) -
#2835Fixed clearing of persistence options in uniqueness validator. -
#2826Dynamic fields are now properly mongoized. -
#2822Marshal load of relations now properly reapplies extensions. -
#2821Autosaved relations should be duped in inheriting classes.
3.0.22
Resolved Issues
-
#2812Fixed criteria on many to many relations when the base document is destroyed and the foreign key has not yet been lazy evaluated. -
#2796Don't cascade changes on has_many relations when assigning with a delete. -
#2795Fix precision on time conversions. (Tom de Bruijn) -
#2794Don't autobuild when reading a relation for validation. -
#2790becomesnow copies embedded documents even if they were protected by mass assignment. -
#2787Allowbecomesto replace the document in the identity map. -
#2786Fixed regressed cascading callbacks on destroy not firing. -
#2784Fixed uniqueness validation properly getting added to subclasses. (Takeshi Akima)
3.0.21
Resolved Issues
#2781/ *#2777- Fixed issue with serialization ofDateTimethat was only present in Rails environments.
3.0.20
Resolved Issues
-
#2774Ensure validations macros for uniqueness, presence, and associated are also available at the instance level. -
#2772Localized fields are now properly handled when cloning a document. -
#2758Mongoid.create_indexesdoes not fail when cannot constantize class. (Arthur Neves) -
#2743Persistence options are no longer cleared when loading revisions. (Arthur Neves) -
#2741Fix time mongoization usec rounding errors on MRI and JRuby. -
#2740Support integer keys in hash fields when usingread_attributewith dot notation. -
#2739Ensure integer deserialization properly casts to integers. -
#2733Many to many relations withinverse_of: nildo not persist the inverse relation on<<orpushif the document is already persisted. -
#2705Fixed logic around when children can be added to the cascading callbacks list.
3.0.19
Resolved Issues
- Released to revert the changes in
#2703.
3.0.18
Resolved Issues
-
#2707Callingfind_or_create_byorfind_by_initialize_byoff a relation with a chained criteria or scope now properly keeps the relations intact on the new or found document. -
#2699Resetting a field now removes the name from the changed attributes list. (Subhash Bhushan) -
#2683Aliased fields are now supported when executing atomic operations from criteria. (Arthur Neves) -
#2678CallingCriteria#sumwith no matching documents returns0instead ofnil. -
#2671Matchers now correctly handle symbol keys. (Jonathan Hyman)
3.0.17
Resolved Issues
#2686Fixed the broken Moped dependency - Moped now must be at least at version 1.2.0.
3.0.16
Resolved Issues
-
#2661Implement instance levelmodel_namefor documents. -
#2651EnsureCriteria#typeworks properly with both symbol and string keys in the selector. -
#2647Ensuredeleted?anddestroyed?on paranoid documents return the same value. -
#2646Setunloaded doc in memory on enumerable targets before yielding to the block. -
#2645Take caching into consideration when asking for counts. (Arthur Nogueira Neves) -
#2642Don't batch push empty arrays on embedded documents. (Laszlo Bacsi) -
#2639Avoid extra unnecesary queries on new records when building relations off of them. -
#2638When a criteria is eager loading, callingfirstorlastthen iterating the entire results properly eager loads the full request. -
#2618Validating uniqueness now always uses string consistency by default. -
#2564Fixed infinite recursion for cases where a relation getter was overridden and called the setter from that method. -
#2554Ensureunscopedon anembeds_manydoes not include documents flagged for destruction.
3.0.15
Resolved Issues
-
#2630Fix cascading when the metadata exists but no cascade defined. -
#2625FixMarshal.dumpandMarshal.loadof proxies and criteria objects. -
#2619Fixed the classes returned byobserved_classeson an observer when it is observing custom models. -
#2612DocumentNotFounderrors now expose the class in the error instance. -
#2610Ensure callingfirstafter alastthat had sorting options resets the sort. -
#2604Check pulls and pushes for conflicting updates. (Lucas Souza) -
#2600Instantiate the proper class type for attributes when using multi parameter attributes. (xxswingxx) -
#2598Fixed sorting on localized fields with embedded docs. -
#2588Block defining methods for dynamic attributes that would be invalid ruby methods. (Matt Sanford) -
#2587Fix method clash withbelongs_toproxies when resetting relation unloaded criteria. -
#2585Ensure session configuration options get passed to Moped as symbols. -
#2584Allow map/reduce to operate on secondaries if output is set toinline. -
#2582Ensurenilsession override can never cause to access a session with namenil. -
#2581Use strong consistency when reloading documents. (Mark Kremer)
3.0.14
Resolved Issues
-
#2575Prevent end of month times from rounding up since floats are not precise enough to handle usec. (Steve Valaitis) -
#2573Don't use i18n for inspection messages. -
#2571Remove blank error message from locales. (Jordan Elver) -
#2568Fix uniqueness validation for localized fields when a scope is also provided. -
#2552EnsureInvalidPatherrors are raised when embedded documents try to get paths from a root selector.
3.0.13
Resolved Issues
#2548Fix error when generating config file with a fresh app with Unicorn in the gemset.
3.0.12
Resolved Issues
-
#2542Allow embedded documents usingstore_asto properly alias in criteria. -
#2541Ensure that the type change is correct when upcasting/downcasting a document viaDocument#becomes(Łukasz Bandzarewicz) -
#2529Fields on subclasses that override fields in the parent where both have defaults with procs now properly override the default in the subclass. -
#2528Aliased fields need to be duped when subclassing. -
#2527Ensure removal of docs in ahas_manydoes a multi update when setting to an empty array.
3.0.11
Resolved Issues
-
#2522FixedCriteria#withto return the criteria and not the class. -
#2518Fix unit of work call for the identity map when using Passenger. -
#2512Ensure nested attributes destroy works with the delayed destroys introduced in 3.0.10 when multiple levels deep. -
#2509Don't hit identity map an extra time when the returned value is an empty hash. (Douwe Maan)
3.0.10
Resolved Issues
-
#2507Ensure no extra db hits when eager loading has a mix of parents with and without docs. (Douwe Maan) -
#2505Ensureupdateandupdate_allfrom criteria properly handle aliased fields. (Dmitry Krasnoukhov) -
#2504Model#becomesproperly keeps the same id. -
#2498Criteria now properly pass provided blocks thoughmethod_missing. -
#2496Embedded documents that were previously stored without ids now properly update and get assigned ids from within Mongoid. -
#2494All explicit atomic operations now properly respect aliased fields. -
#2493UseClass#nameinstead ofClass#model_namewhen setting polymorphic types in casemodel_namehas been overridden. -
#2491Removed unnecessary merge call in cascadable children. -
#2485Removing indexes now always uses strong consistency. -
#2483Versioning now handles localized fields. (Lawrence Curtis) -
#2482Store find parameters in theDocumentNotFounderror. -
#2481Map/reduce aggregations now properly handle Mongo's batching of reduce jobs in groups of 100 with the state being passed through on the count. -
#2476Handle skip and limit outside of range on embeds_many relations gracefully. -
#2474Correctly detach 1-1 relations when the child is not yet loaded. (Kostyantyn Stepanyuk) -
#2451relation.deletedon embedded paranoid documents now works properly again. -
#2472Ensureupdate_allon embedded relations works properly when nothing is actually going to be updated. -
#2469Nullified documents on relations are now able to be re-added with the same in memory instance. -
#2454Model#as_documentproperly allows changes from having a relation to the relation being removed. (James Almond) -
#2445Mongoidmiddleware now properly supports both normal and streamed responses and properly clears the identity map for either. -
#2367Embedded documents that are to be deleted via nested attributes no longer become immediately removed from the relation in case the parent validation fails. Instead, they get flagged for destruction and then the removal occurs upon the parent passing validation and going to persist.Note this is a behavior change, but since the API does not change and the previous behavior was incorrect and did not match AR this was able to go into a point release.
3.0.9
Resolved Issues
-
#2463Fixed the brokenrails g mongoid:configfrom a fresh repo. -
#2456The descendants cache is now reset when the document is inherited again. (Kostyantyn Stepanyuk) -
#2453Model#write_attributenow properly works with aliased fields. (Campbell Allen) -
#2444Removed extra dirty methods creation call. (Kostyantyn Stepanyuk) -
#2440/\#2435 Pass mass assignment options down to children when setting via nested attributes or embedded documents. -
#2439Fixed memory leak in threaded selection of returned fields. (Tim Olsen) -
mongoid/moped#82 Aliased fields now work with
Criteria#distinct. -
#2423Fixed embedded document'supdate_allto perform the correct $set when using off a criteria. -
#2414Index definitions now respect aliased fields. -
#2413Enumerable targets now properly return enumerators when no blocks are provided. (Andrew Smith) -
#2411BigDecimalfields are properly stored as strings when mongoizing integers and floats. -
#2409Don't warn about missing mongoid.yml if configured programmatically. -
#2403Return false onupdate_allof an embeds many with no documents. -
#2401Bring back the ability to merge a criteria with a hash. -
#2399Reject blank id values on has_manyModel#object_ids=. (Tiago Rafael Godinho) -
#2393Ensureinverse_ofis respected when using polymorphic relations. -
#2388Map/reduce properly usessortinstead oforderbyin the execution of the command. (Alex Tsibulya) -
#2386Allow geo haystack and bits parameters in indexes. (Bradley Rees) -
#2380Model#becomesnow properly copies over dirty attributes. -
#2331Don't double push child documents when extra saves are called in an after_create callback.
3.0.8 (Yanked)
3.0.6
Resolved Issues
-
#2375Uniqueness validation scoping now works with aliased fields. -
#2372Ensure that all atomic operations mongoize values before executing. -
#2370Paranoid documents now properly don't get deleted when usingdependent: :restrictand an exception is raised. -
#2365Don't do anything when trying to replace an embeds_one with the same document. -
#2362Don't store inverse of field values in the database when they are not needed. (When there is not more than one polymorphic parent defined on the same class). -
#2360Cloning documents should ignore mass assignment protection rules. -
#2356When limiting fields returned in queries viaonlyensure that the limitation is scoped to the model. -
#2353Allowupdate_attributeto properly handle aliased fields. -
#2348Conversion of strings to times should raise an argument error if the string is invalid. (Campbell Allen) -
#2346Ensurebelongs_torelations are evolvable when passed the proxy and not the document. -
#2334Fixed aggregation map/reduce when fields sometimes do not exist. (James McKinney) -
#2330Fixed inconsistency of#sizeand#lengthon criteria when the documents have been iterated over with a limit applied. -
#2328Ensure ordering is applied on all relation criteria if defined. -
#2327Don't execute callbacks from base document if the document cannot execute them. -
#2318Ensure setting any numeric on aFloatfield actually sets it as a float, even if the number provided is an integer.
3.0.5
Resolved Issues
-
#2313Fixed deserialization ofnilTimeWithZonefields. (nagachika) -
#2311Document#changesno longer returnsnilvalues forArrayandHashfields that were only accessed and didn't actually change. Regression from 2.4.x. -
#2310Setting a many to many duplicate successively in memory no longer clears the inverse foreign keys. -
#2309Allow embeds_one relations to be set with hashes more than just the initial set. -
#2308Ensure documents retrieved via#findonhas_manyandhas_and_belongs_to_manyrelations are kept in memory. -
#2304Default scopes now properly merge instead of overwrite when more than one is defined as per expectations with AR. (Kirill Maksimov) -
#2300Ensure reloading refreshes the document in the identity map. -
#2298Protect against many to many relations pulling a null set of ids. (Jonathan Hyman) -
#2291Fixed touch operations only to update the timestamp and the optional field, no matter what the other changes on the document are. -
#1091Allow presence validation to pass if the value isfalse.
3.0.4
Resolved Issues
-
#2280Fix synchronization of many-to-many relations when an ordering default scope exists on either side of the association. -
#2278Criteria#updatenow properly updates only the first matching document, whereCriteria#update_allwill update all matching documents. (no flag vs multi). -
#2274When loading models, warn if error is raised but continue processing. -
#2272Don't wipe selectors or options when removing the default scope for actual nil values. Must check if key exists as well. -
#2266Restored paranoid documents are no longer flagged as destroyed. (Mario Uher) -
#2263Ensure casting of non object id foreign keys on many to many relations happens in the initial set, not at validation time.
3.0.3
Resolved Issues
-
#2259Ensure subclassed documents can not be pulled from the identity map via an id of another document in the same collection with a parent or sibeling type. -
#2254$inc operations no longer convert all values to floats. -
#2252Don't fire autosave when before callbacks have terminated. -
#2248Improved the performance ofexists?on criteria and relations. (Jonathan Hyman)
3.0.2
Resolved Issues
-
#2244Get rid of id mass assignment warnings in nested attributes. -
#2242Fix eager loading not to load all documents when calling first or last. -
#2241Map/reduce operations now always use strong consistency since they have the potential to write to collections, most of the time. -
#2238Ensure n-n foreign key fields are flagged as resizable to preventnil->[]changes when using#onlyand updating. -
#2236Keep the instance of the document in the validations exception accessible viadocumentorrecord. -
#2234Ensure validations when document is getting persisted with custom options work properly with custom options, and do not clear them out if validation passes. -
#2224Model#incnow acceptsBigDecimalvalues. -
#2216Fixed assignment of metadata on embeds one relations when setting multiple times in a row. -
#2212Ensure errors are cleared after a save withvalidate: falsein all situations. -
#2207When eager loading ids the query must be duped to avoid multiple iteration problems not getting the required fields. -
#2204Raise anInvalidIncludeserror when passing arguments toCriteria.includesthat are invalid (not relations, or more than 1 level.) -
#2203Map/Reduce now works properly in conjunction withModel#with.Band. with(session: "secondary"). where(:likes.gt => 100). map_reduce(map, reduce). out(inline: 1) -
#2199Autosave false is now respected when automatically adding presence validation. (John Nishinaga)
3.0.1
Resolved Issues
-
#2191Ensure proper visibility (private) for error message generation methods. -
#2187Ensure all levels of nested documents are serialized in json. -
#2184Allow names of relations that conflict with ruby core kernel methods to pass existence checks. -
#2181Ensure.firstcriteria sort by ascending ids, if no other sorting criteria was provided.
3.0.0
New Features
-
#2151When asking for metadata before persistence,Mongoidwill now raise aMongoid::Errors::NoMetadataerror if the metadata is not present. -
#2147Model#becomesnow copies over the embedded documents. -
A new callback has been introduced:
upsert, which runs when callingdocument.upsertsince Mongoid does not know if the document is to be treated as new or persisted. With this come the model callbacks:before_upsert after_upsert around_upsert -
#2080/\#2087 The database or session thatMongoidpersists to can now be overridden on a global level for cases whereModel#withis not a viable option.Mongoid.override_database(:secondary) Mongoid.override_session(:secondary) Band.create(name: "Placebo") #=> Persists to secondary. band.albums.create #=> Persists to secondary. Note that this option is global and overrides for all models on the current thread. It is the developer's responsibility to remember to set this back to nil if you no longer want the override to happen. Mongoid.override_database(nil) Mongoid.override_session(nil) -
#1989Criteriacount,sizeandlengthnow behave as Active Record with regards to database access.`Criteria#count` will always hit the database to get the count. `Criteria#length` and `Criteria#size` will hit the database once if the criteria has not been loaded, and subsequent calls will return the cached value. If the criteria has been iterated over or loaded, `length` and `size` will never hit the db. -
#1976Eager loading no longer produces queries when the base query returns zero results. -
Model.find_bynow accepts a block and will yield to the found document if it is not nil.Band.find_by(name: "Depeche Mode") do |band| band.likes = 100 end -
#1958/\#1798 Documents andbelongs_torelations now support touch.class Band include Mongoid::Document include Mongoid::Timestamps::Updated belongs_to :label, touch: true end Update the document's updated_at timestamp to the current time. This will also update any touchable relation's as well. Band.first.touch Update a specific time field along with the updated_at. Band.first.touch(:founded) This fires no validations or callbacks. -
Mongoidnow supports MongoDB's $findAndModify command.Band.find_and_modify("$inc" => { likes: 1 }) Band.desc(:name).only(:name).find_and_modify( { "$inc" => { likes: 1 }}, new: true ) -
#1906Mongoidwill retrieve documents from the identity map when providing multiple ids to find. (Hans Hasselberg) -
#1903Mongoidraises an error if provided a javascript expression to a where clause on an embedded collection. (Sebastien Azimi) -
Aggregations now adhere to both a
MongoidAPI and their enumerable counterparts where applicable.Band.min(:likes) Band.min do |a, b| a.likes <=> b.likes end Band.max(:likes) Band.max do |a, b| a.likes <=> b.likes end Note that when providing a field name and no block, a single numeric value will be returned, but when providing a block, a document will be returned which has the min/max value. This is since Ruby's Enumerable API dictates when providing a block, the matching element is returned. When providing a block, all documents will be loaded into memory. When providing a symbol, the execution is handled via map/reduce on the server. -
A kitchen sink aggregation method is now provided, to get everything in in a single call for a field.
Band.aggregates(:likes) # => # { # "count" => 2.0, # "max" => 1000.0, # "min" => 500.0, # "sum" => 1500.0, # "avg" => 750.0 # } -
A DSL off the criteria API is now provided for map/reduce operations as a convenience.
Band.where(name: "Tool").map_reduce(map, reduce).out(inline: 1) Band.map_reduce(map, reduce).out(replace: "coll-name") Band.map_reduce(map, reduce).out(inline: 1).finalize(finalize) -
Mongoidnow uses Origin for its Criteria API. See the Origin repo and API docs for the documentation. -
#1861Mongoidnow raises anAmbiguousRelationshiperror when it cannot determine the inverse of a relation and there are multiple potential candidates. (Hans Hasselberg) -
You can now perform an explain directly from criteria.
Band.where(name: "Depeche Mode").explain -
#1856Push on one to many relations can now be chained.band.albums.push(undertow).push(aenima) -
#1842MultiParameterAttributes now supported aliased fields. (Anton Orel) -
#1833If an embedded document is attempted to be saved with no parent defined, Mongoid now will raise aMongoid::Errors::NoParentexception. -
Added an ORM-agnostic way to get the field names
class Band include Mongoid::Document field :name, type: String end Band.attribute_names -
#1831find_or_create_byon relations now takes mass assignment and type options. (Tatsuya Ono)class Band include Mongoid::Document :albums end band.albums.find_or_create_by({ name: "101" }, LP) -
#1818Add capability to choose the key where yourembeds_manyrelation is stores. (Cyril Mougel)class User include Mongoid::Document field :name, type: String :prefs, class_name: "Preference", store_as: 'my_preferences' end user.prefs.build(value: "ok") user.save # document saves in MongoDB as: # { "name" => "foo", "my_preferences" => [{ "value" => "ok" }]} -
#1806Model.find_or_create_byandModel.find_or_initialize_bycan now take documents as parameters for belongs_to relations.person = Person.first Game.find_or_create_by(person: person) -
#1774Relations now have a:restrictoption for dependent relations which will raise an error when attempting to delete a parent that still has children on it. (Hans Hasselberg)class Band include Mongoid::Document has_many :albums, dependent: :restrict end band = Band.first band.albums << Albums.first band.delete # Raises DeleteRestriction error. -
#1764Add method to check if field differs from the default value.class Band include Mongoid::Document field :name, type: String, default: "New" end band = Band.first band.name_changed_from_default? -
#1759Invalid fields error messages have been updated to show the source and location of the original method. The new message is:Problem: Defining a field named 'crazy_method' is not allowed. Summary: Defining this field would override the method 'crazy_method', which would cause issues with expectations around the original method and cause extremely hard to debug issues. The original method was defined in: Object: MyModule File: /path/to/my/module.rb Line: 8 Resolution: Use Mongoid.destructive_fields to see what names are not allowed, and don't use these names. These include names that also conflict with core Ruby methods on Object, Module, Enumerable, or included gems that inject methods into these or Mongoid internals. -
#1753/#1649 A setter and getter for has_many relations to set its children is now provided. (Piotr Jakubowski)class Album include Mongoid::Document has_many :engineers end class Engineer include Mongoid::Document belongs_to :album end album = Album.first engineer = Engineer.first album.engineer_ids = [ engineer.id ] album.engineer_ids # Returns the ids of the engineers. -
#1741Mongoidnow provides a rake task to force remove indexes for environments where Mongoid manages the index definitions and the removal should be automated. (Hans Hasselberg)rake db:force_remove_indexes rake db:mongoid:force_remove_indexes -
#1726Mongoid.load!now accepts an optional second argument for the environment to load. This takes precedence over any environment variable that is set if provided.Mongoid.load!("/path/to/mongoid.yml", :development) -
#1724Mongoidnow supports regex fields.class Rule include Mongoid::Document field :pattern, type: Regexp, default: /[^abc]/ end -
#1714/\#1706 Added better logging on index creation. (Hans Hasselberg)When an index is present on a root document model: Creating indexes on: Model for: name, dob. When an index is defined on an model: Index ignored on: Address, please define in the root model. When no index is defined, nothing is logged, and if a bad index is defined an error is raised. -
#1710For cases when you don't wantMongoidto auto-protect the id and type attributes, you can set a configuration option to turn this off.Mongoid.protect_sensitive_fields = false -
#1685Belongs to relations now have build_ and create_ methods.class Comment include Mongoid::Document belongs_to :user end comment = Comment.new comment.build_user # Build a new user object comment.create_user # Create a new user object -
#1684Raise a::Mongoid::Errors::InverseNotFoundwhen attempting to set a child on a relation without the proper inverse_of definitions due to Mongoid not being able to determine it.class Car include Mongoid::Document :engine, class_name: "Motor" end class Motor include Mongoid::Document :machine, class_name: "Car" end car = Car.new car.engine = Motor.new # raises an InverseNotFound error. -
#1680Polymorphic relations now use*_typekeys in lookup queries.class User include Mongoid::Document has_many :comments, as: :commentable end class Comment include Mongoid::Document belongs_to :commentable, polymorphic: true end user = User.find(id) user.comments # Uses user.id and type "User" in the query. -
#1677Support for parent separable polymorphic relations to the same parent class is now available. This only works if set from the parent side in order to know which relation the children belong to. (Douwe Maan)class Face include Mongoid::Document has_one :left_eye, class_name: "Eye", as: :visible has_one :right_eye, class_name: "Eye", as: :visible end class Eye include Mongoid::Document belongs_to :visible, polymorphic: true end face = Face.new right_eye = Eye.new left_eye = Eye.new face.right_eye = right_eye face.left_eye = left_eye right_eye.visible = face # Will raise an error. -
#1650Objects that respond toto_criteriacan now be merged into existing criteria objects.class Filter def to_criteria # return a Criteria object. end end criteria = Person.where(title: "Sir") criteria.merge(filter) -
#1635All exceptions now provide more comprehensive errors, including the problem that occurred, a detail summary of why it happened, and potential resolutions. Example:(Mongoid::Errors::DocumentNotFound) Problem: Document not found for class Town with id(s) [BSON::ObjectId('4f35781b8ad54812e1000001')]. Summary: When calling Town.find with an id or array of ids, each parameter must match a document in the database or this error will be raised. Resolution: Search for an id that is in the database or set the Mongoid.raise_not_found_error configuration option to false, which will cause a nil to be returned instead of raising this error. -
#1616Model.find_byadded which takes a hash of arguments to search for in the database. If no single document is returned a DocumentNotFound error is raised. (Piotr Jakubowski)Band.find_by(name: "Depeche Mode") -
#1606Mongoidnow enables autosave, like Active Record, when adding an accepts_nested_attributes_for to a relation.class Band include Mongoid::Document has_many :albums accepts_nested_attributes_for :albums # This enables the autosave. end -
#1477Mongoidnow automatically protects the id and type attributes from mass assignment. You can override this (not recommended) by redefining them as accessible.class Band include Mongoid::Document attr_accessible :id, :_id, :_type end -
#1459The identity map can be disabled now for specific code execution by passing options to the unit of work.Mongoid.unit_of_work(disable: :all) do # Disables the identity map on all threads for the block. end Mongoid.unit_of_work(disable: :current) do # Disables the identity map on the current thread for the block. end Mongoid.unit_of_work do # Business as usual. end -
#1355Associations now can have safety options provided to them on single document persistence operations.band.albums.with(safe: true).push(album) band.albums.with(safe: true).create(name: "Smiths") album.with(safe: true).create_producer(name: "Flood") -
#1348Eager loading is now supported on many-to-many relations. -
#1292Remove attribute now unsets the attribute when the document is saved instead of setting to nil.band = Band.find(id) band.remove_attribute(:label) # Uses $unset when the document is saved. -
#1291Mongoiddatabase sessions are now connected to lazily, and are completely thread safe. If a new thread is created, then a new database session will be created for it. -
#1291Mongoidnow supports any number of database connections as defined in the mongoid.yml. For example you could have a local single server db, a multi availability zone replica set, and a shard cluster all in the same application environment. Mongoid can connect to any session at any point in time. -
#1291Mongoidnow allows you to persist to whatever database or collection you like at runtime, on a per-query or persistence operation basis by usingwith.Band.with(collection: "artists").create(name: "Depeche Mode") band.with(database: "secondary).save! Band.with(collection: "artists").where(name: "Depeche Mode") -
#1291You can now configure on a per-model basis where its documents are stored with the new and improvedstore_inmacro.class Band include Mongoid::Document store_in collection: "artists", database: "secondary", session: "replica" end This can be overridden, of course, at runtime via the `with` method. -
#1212Embedded documents can now be popped off a relation with persistence.band.albums.pop # Pop 1 document and persist the removal. band.albums.pop(3) # Pop 3 documents and persist the removal. -
#1188Relations now have existence predicates for simplified checking if the relation is blank or not. (Andy Morris)class Band include Mongoid::Document :albums :label end band = Band.new band.albums? band.has_albums? band.label? band.has_label? -
#11881-1 relations now have an:autobuildoption to indicate if the relation should automatically be build with empty attributes upon access where the relation currently does not exist. Works on embeds_one, embedded_in, has_one, belongs_to. (Andy Morris)class Band include Mongoid::Document has_one :label, autobuild: true end band = Band.new band.label # Returns a new label with empty attributes. When using existence checks, autobuilding will not execute. band = Band.new band.label? # Returns false, does not autobuild on a check. band.has_label? # Returns false, does not autobuild on a check. -
#1081Mongoidindexes both id and type as a compound index when providingindex: trueto a polymorphic belongs_to.class Comment include Mongoid::Document # Indexes commentable_id and commentable_type as a compound index. belongs_to :commentable, polymorphic: true, index: true end -
#1053Raise a::Mongoid::Errors::UnknownAttributeinstead of no method when attempting to set a field that is not defined and allow dynamic fields is false. (Cyril Mougel)Mongoid.allow_dynamic_fields = false class Person include Mongoid::Document field :title, type: String end Person.new.age = 50 # raises the UnknownAttribute error. -
#772Fields can now be flagged as readonly, which will only let their values be set when the document is new.class Band include Mongoid::Document field :name, type: String field :genre, type: String attr_readonly :name, :genre end Readonly values are ignored when attempting to set them on persisted documents, with the exception of update_attribute and remove_attribute, where errors will get raised. band = Band.create(name: "Depeche Mode") band.update_attribute(:name, "Smiths") # Raises ReadonlyAttribute error. band.remove_attribute(:name) # Raises ReadonlyAttribute error.
Major Changes (Backwards Incompatible)
-
Polymorphic relations can not have ids other than object ids. This is because Mongoid cannot properly figure out in an optimized way what the various classes on the other side of the relation store their ids as, as they could potentially all be different.
This was not allowed before, but nowhere was it explicitly stated.
-
#2039Validating presence of a relation now checks both the relation and the foreign key value. -
Indexing syntax has changed. The first parameter is now a hash of name/direction pairs with an optional second hash parameter for additional options.
Normal indexing with , directions are either 1 or -1: class Band include Mongoid::Document field :name, type: String index({ name: 1 }, { unique: true, background: true }) end Geospacial indexing needs "2d" as its direction. class Venue include Mongoid::Document field :location, type: Array index location: "2d" end -
Custom serializable fields have revamped. Your object no longer should include
Mongoid::Fields::Serializable- instead it only needs to implement 3 methods:#mongoize,.demongoizeand.evolve.`#mongoize` is an instance method that transforms your object into a mongo-friendly value. `.demongoize` is a class method, that can take some data from mongo and instantiate and object of your custom type. `.evolve` is a class method, that can take any object, and transform it for use in a `Mongoid::Criteria`. An example of an implementation of this for `Range`: class Range def mongoize { "min" => first, "max" => last } end class << self def demongoize(object) Range.new(object["min"], object["max"]) end def evolve(object) { "$gte" => object.first, "$lte" => object.last } end end end -
Document#changesis no longer a hash with indifferent access. -
after_initializecallbacks no longer cascade to children if the option is set. -
#1865counton the memory and mongo contexts now behave exactly the same as Ruby'scounton enumerable, and can take an object or a block. This is optimized on the mongo context not to load everything in memory with the exception of passing a block.Band.where(name: "Tool").count Band.where(name: "Tool").count(tool) # redundant. Band.where(name: "Tool") do |doc| doc.likes > 0 end Note that although the signatures are the same for both the memory and mongo contexts, it's recommended you only use the block syntax for the memory context since the embedded documents are already loaded into memory. Also note that passing a boolean to take skip and limit into account is no longer supported, as this is not necessarily a useful feature. -
The
autocreate_indexesconfiguration option has been removed. -
Model.defaultsno longer exists. You may get all defaults with a combination ofModel.pre_processed_defaultsandModel.post_processed_defaults.Band.pre_processed_defaults Band.post_processed_defaults -
Model.identityandModel.keyhave been removed. For custom ids, users must now override the _id field.When the default value is a proc, the default is applied *after* all other attributes are set. class Band include Mongoid::Document field :_id, type: String, default: ->{ name } end To have the default applied *before* other attributes, set `:pre_processed` to true. class Band include Mongoid::Document field :_id, type: String, pre_processed: true, default: ->{ BSON::ObjectId.new.to_s } end -
Custom application exceptions in various languages has been removed, along with the
Mongoid.add_languagefeature. -
Mongoidno longer supports 1.8. MRI 1.9.3 and higher, or JRuby 1.6 and higher in 1.9 mode are only supported. -
#1734When searching for documents viaModel.findwith multiple ids, Mongoid will raise an error if not all ids are found, and tell you what the missing ones were. Previously the error only got raised if nothing was returned. -
#1675Adding presence validation on a relation now enables autosave. This is to ensure that when a new parent object is saved with a new child and marked is valid, both are persisted to ensure a correct state in the database. -
#1491Ensure empty translations returns an empty hash on access. -
#1484Model#has_attribute?now behaves the same as Active Record. -
#1471Mongoidno longer strips any level of precision off of times. -
#1475Active support's time zone is now used by default in time serialization if it is defined. -
#1342Model.findandmodel.relation.findnow only take a single or multiple ids. The first/last/all with a conditions hash has been removed. -
#1291The mongoid.yml has been revamped completely, and upgrading existing applications will greet you with some lovely Mongoid specific configuration errors. You can re-generate a new mongoid.yml via the existing rake task, which is commented to an insane degree to help you with all the configuration possibilities. -
#1291Thepersist_in_safe_modeconfiguration option has been removed. You must now tell a database session in the mongoid.yml whether or not it should persist in safe mode by default.production: sessions: default: database: my_app_prod hosts: - db.app.com:27018 - db.app.com:27019 : consistency: :eventual safe: true -
#1291safelyandunsafelyhave been removed. Please now usewithto provide safe mode options at runtime.Band.with(safe: true).create band.with(safe: { w: 3 }).save! Band.with(safe: false).create! -
#1270Relation macros have been changed to match their AR counterparts: only :has_one, :has_many, :has_and_belongs_to_many, and :belongs_to exist now. -
#1268Model#new?has been removed, developers must now always useModel#new_record?. -
#1182A reload is no longer required to refresh a relation after setting the value of the foreign key field for it. Note this behaves exactly as Active Record.If the id is set, but the document for it has not been persisted, accessing the relation will return empty results. If the id is set and its document is persisted, accessing the relation will return the document. If the id is set, but the base document is not saved afterwards, then reloading will return the document to its original state. -
#1093Field serialization strategies have changed onArray,Hash,Integerand Boolean to be more consistent and match AR where appropriate.Serialization of arrays calls `Array.wrap(object)` Serialization of hashes calls `Hash[object]` (to_hash on the object) Serialization of integers always returns an int via `to_i` Serialization of booleans defaults to false instead of nil. -
#933:field.sizehas been renamed to:field.countin criteria for $size not to conflict with Symbol's size method. -
#829/\#797Mongoidscoping code has been completely rewritten, and now matches the Active Record API. With this backwards incompatible change, some methods have been removed or renamed.Criteria#as_conditions and Criteria#fuse no longer exist. Criteria#merge now only accepts another object that responds to `to_criteria`. Criteria#merge! now merges in another object without creating a new criteria object. Band.where(name: "Tool").merge!(criteria) Named scopes and default scopes no longer take hashes as parameters. From now on only criteria and procs wrapping criteria will be accepted, and an error will be raised if the arguments are incorrect. class Band include Mongoid::Document default_scope ->{ where(active: true) } scope :inactive, where(active: false) scope :invalid, where: { valid: false } # This will raise an error. end The 'named_scope' macro has been removed, from now on only use 'scope'. Model.unscoped now accepts a block which will not allow default scoping to be applied for any calls inside the block. Band.unscoped do Band.scoped.where(name: "Ministry") end Model.scoped now takes that will be set directly on the criteria hash. Band.scoped(skip: 10, limit: 20) -
#463Document#upsertis no longer aliased toDocument#saveand now actually performs a proper MongoDB upsert command when called. If you were using this method before and want the same behavior, please switch tosave.band = Band.new(name: "Tool") band.upsert #=> Inserts the document in the database. band.name = "Placebo" band.upsert #=> Updates the existing document.
Resolved Issues
-
#2166Criteria#from_map_or_dbstrips type selection when eager loading since it will check if the type is correct after. -
#2129Fixed sorting for all fields on embeds many relations. -
#2124Fixed default scope and deleted scope on paranoid documents. -
#2122Allow embedded documents to sort on boolean fields. -
#2119AllowCriteria#update_allto accept atomic ops and normal sets. -
#2118Don't strip any precision duringDateTime->Timeconversions. -
#2117Ensure embeds one relations have callbacks run when using nested attributes. -
#2110Model#touchnow works properly on embedded documents. -
#2100Allow atomic operations to properly execute on paranoid documents that have a deleted_at set. -
#2089Allow proper separation of mongoization and evolving with respect to foreign keys. -
#2088Allow finds by string ids to pull from the identity map if the ids are stored as object ids. -
#2085Allow demongoization of floats and ints to big decimals. -
#2084Don't cascade if metadata does not exist. -
#2078CallingModel#cloneorModel#dupnow properly sets attributes as dirty. -
#2070Allow for updated_at to be overridden manually for new documents that also have a created_at. -
#2041Don't hit the database multiple times on relation access after an eager load returned zero documents. -
#1997Cascading callbacks should be able to halt the callback chain when terminating. -
#1972added,loaded, andunloadedcan now be valid scope names on a document that is part of a 1-n relation. -
#1952/#1950#all_inbehavior on embedded documents now properly matches root documents when passing an empty array. (Hans Hasselberg) -
#1941/#1939Model.find_bynow returns nil if raise not found error is set to false. (Hans Hasselberg) -
#1859/#1860Model#remove_attributenow properly unsets on embedded documents. (Anton Onyshchenko) -
#1852Ensure no infinite recursion on cascading callbacks. (Ara Howard) -
#1823Relation#includes?now properly works with identity map enabled. -
#1810Model#changed?no longer returns true when hash and array fields have only been accessed. -
#1876/\#1782 Allow dot notation in embeds many criteria queries. (Cyril Mougel) -
#1745Fixed batch clear to work within attribute setting. -
#1718Ensure consistency of#first/#last in relations - they now always match first/last in the database, but opts for in memory first. -
#1692/\#1376Model#updateattributesandModel#update_attributes!now accept assignment options. (Hans Hasselberg) -
#1688/\#1207 Don't require namespacing when providing class name on relation macros inside the namespace. (Hans Hasselberg) -
#1665/\#1672 Expand complex criteria in nested criteria selectors, like #matches. (Hans Hasselberg) -
#1335Don't add id sorting criteria to first/last is there is already sorting options on the criteria. -
#1321Referenced many enumerable targets are now hash-backed, preventing duplicates in a more efficient manner. -
#1135DateTimes now properly get time zones on deserialization. -
#1031Mongoidnow serializes values inArrayfields to their proper Mongo-friendly values when possible. -
#685Attempting to use versioning with embedded documents will now raise a proper error alerting the developer this is not allowed.
2.6.0
New Features
#2709Backported thetouchfunctionality fromMongoid3.
2.5.2
Resolved Issues
#2502Fixed cache key to properly handle when the document does not includeMongoid::Timestamps::Updated. (Arthur Nogueira Neves)
2.5.1
Resolved Issues
-
#2492Backport cascading callbacks performance and memory fixes from 3.0.0-stable. -
#2464Backport the nested attributes fix for keeping many relations in memory when updating attributes. (Chris Thompson)
2.5.0
New Features
- This is a release to support the 1.7.0 and higher Mongo and
BSONgems and resolves issues that kept the 2.4.x series locked below 1.6.2
2.4.12
Resolved Issues
-
#2178Ensure destroy callbacks are run post replacement of an embeds one relation. -
#2169Allow saves to pass when documents are destroyed after the save in a callback. -
#2144Uniqueness validation on paranoid documents now properly scopes. -
#2127Don't unbind parents of embedded documents mid nested attributes deletion.
2.4.11
Resolved Issues
-
This release forces a cap on the mongo driver version at 1.6.2 due to changes in the
Mongo::Connection.from_uriAPI not allowing valid connection options anymore. -
#2040Fixed bad interpolation for locale presence validation. -
#2038Allow inverse relations to be determined by foreign keys alone if defined on both sides, not just an inverse_of declaration. -
#2023Allow serialization of dynamic types that conflict with core Ruby methods to still be serialized. -
#2008Presence validation should hit the db to check validity if the relation in memory is blank. -
#2006Allow excluding only the _id field post execution of an#onlycall.
2.4.10
Resolved Issues
-
#2003Don't fail on document generation when an embedded document was stored as nil in the database. -
#1997Don't delete paranoid embedded docs via nested attributes when a before_destroy callback returns false. -
#1994dependent: :deleteonly hits the database once now for one to many and many to many relations instead of once for each document. -
#1987Don't double-insert documents into identity map when eager loading twice inside the unit of work. -
#1953Uniqueness validation now works on localized fields. -
#1936Allow setting n levels deep embedded documents atomically without conflicting mods when not using nested attributes or documents themselves in an update call from the parent. -
#1957/\#1954 Ensure database name is set with inheritance. (Hans Hasselberg)
2.4.9
Resolved Issues
-
#1943Ensure numericality validation works for big decimals. -
#1938Length validation now works with localized fields. -
#1936Conflicting pushes with other pushes is now properly handled. -
#1933Proxy#extendshould delegate through to the target, where extending the proxy itself is now handled throughProxy#proxy_extend. -
#1930Ensure complex criteria are expanded in all where clauses. (Hans Hasselberg) -
#1928Deletion of embedded documents via nested attributes now performs a $pull with id match criteria instead of a $pullAll to cover all cases. Previously newly added defaults to documents that had already persisted could not be deleted in this matter since the doc did not match what was in the database. -
#1924/\#1917 Fix pushing to embedded relations with default scopes not scoping on the new document. (Hans Hasselberg) -
#1922/\#1919 Dropping collections unmemoizes the internally wrapped collection, in order to ensure when defining capped collections that they are always recreated as capped. (Hans Hasselberg) -
#1916/\#1913 Uniqueness validation no longer is affected by the default scope. (Hans Hasselberg) -
#1943Ensure numericality validation works for big decimals.
2.4.8
Resolved Issues
-
#1892When getting not master operation error,Mongoidshould reconnect before retrying the operation. -
#1887Don't cascade callbacks to children that don't have the callback defined. -
#1882Don't expand duplicate id criterion into an $and with duplicate selections. -
#1878Fixed default application values not to apply in certainonlyorwithoutselection on iteration, not justfirstandlast. -
#1874Fixed the reject all blank proc constant to handle values properly with a destroy non blank value. (Stefan Daschek) -
#1869/\#1868 Delayed atomic sets now uses the atomic path instead of the metadata name to fix multiple level embedding issues. (Chris Micacchi provided specs) -
#1866Post processed defaults (procs) should be applied post binding of the child in a relation.build.
2.4.7
Resolved Issues
-
Ensure reloading of embedded documents retains reference to the parent.
-
#1837Always pass symbol options to the driver. -
#1836Ensure relation counts pick up persisted document that have not had the foreign key link persisted. -
#1820Destroying embedded documents in an embeds_many should also removed the document from the underlying _unscoped target and reindex the relation. -
#1814Don't cascade callbacks on after_initialize. -
#1800Invalid options for the Mongo connection are now filtered out. -
#1785Case equality has been fixed to handle instance checks properly.
2.4.6
Resolved Issues
-
#1772Allow skip and limit to convert strings to integers. (Jean Boussier) -
#1767Model#update_attributesaccepts mass assignment options again. (Hans Hasselberg) -
#1762Criteria#any_ofnow properly handles localized fields. -
#1758Metadata now returns self on options for external library support. -
#1757Ensure serialization converts any attribute types to the type defined by the field. -
#1756Serializable hash options should pass through to embedded docs.
2.4.5
Resolved Issues
-
#1751Mongoid's logger now responds to level for Ruby logging API compatibility. -
#1744/#1750 Sorting works now for localized fields in embedded documents using the criteria API. (Hans Hasselberg) -
#1746Presence validation now shows which locales were empty for localized fields. (Cyril Mougel) -
#1727Allow dot notation in embedded criteria to work on both embeds one and embeds many. (Lyle Underwood) -
#1723Initialize callbacks should cascade through children without needing to determine if the child is changed. -
#1715Serializable hashes are now consistent on inclusion of embedded documents per or post save. -
#1713Fixing === checks when comparing a class with an instance of a subclass. -
#1495Callbacks no longer get the 'super called outside of method` errors on busted 1.8.7 rubies.
2.4.4
Resolved Issues
-
#1705Allow changing the order of many to many foreign keys. -
#1703Updated at is now versioned again. (Lucas Souza) -
#1686Setthe base metadata on unbind as well as bind for belongs to relations. -
#1681Attempt to create indexes for models without namespacing if the namespace does not exist for the subdirectory. -
#1676Allow eager loading to work as a default scope. -
#1665/\#1672 Expand complex criteria in nested criteria selectors, like #matches. (Hans Hasselberg) -
#1668Ensure Mongoid logger exists before calling warn. (Rémy Coutable) -
#1661Ensure uniqueness validation works on cloned documents. -
#1659Clear delayed atomic sets when resetting the same embedded relation. -
#1656/\#1657 Don't hit database for uniqueness validation if BOTH scope and attribute hasn't changed. (priyaaank) -
#1205/\#1642 When limiting fields returned from the database viaCriteria#onlyandCriteria#withoutand then subsequently saving the document. Default values no longer override excluded fields.
2.4.3
Resolved Issues
-
#1647DateTimeserialization when already in UTC does not convert to local time. -
#1641/\#1639Mongoid.observer.disable:allnow behaves as AR does. -
#1640Update consumers should be tied to the name of the collection they persist to, not the name of the class. -
#1637/\#1636 Scopes no longer modify parent class scopes when subclassing. (Hans Hasselberg) -
#1629$all and $in criteria on embedded many relations now properly handles regex searches and elements of varying length. (Douwe Maan) -
#1623/\#1634 Default scopes no longer breakMongoid::Versioning. (Hans Hasselberg) -
#1605Fix regression of rescue responses,Rails3.2
2.4.2
Resolved Issues
-
#1628_type field can once again be included in serialization to json or xml as a global option withinclude_type_for_serialization. (Roman Shterenzon) -
#1627Validating format now works properly with localized fields. (Douwe Maan) -
#1617Relation proxy methods now show up in Mongoid's list of prohibited fields. -
#1615Allow a single configuration of host and port for all spec runs, overridden by setting MONGOID_SPEC_HOST and MONGOID_SPEC_PORT env vars. -
#1610When versioning paranoid documents and max version is set, hard delete old versions from the embedded relation. -
#1609Allow connection retry during cursor iteration as well as all other operations. -
#1608Guard against no method errors when passing ids in nested attributes and the documents do not exist. -
#1605Remove deprecation warning on rescue responses,Rails3.2 -
#1602Preserve structure of $and and $or queries when typecasting. -
#1600Uniqueness validation no longer errors when provided a relation. -
#1599Make sure enumerable targets yield to what is in memory first when performing #each, not always the unloaded first. -
#1597Fix the ability to change the order of array fields with the same elements. -
#1590Allow proper serialization of boolean values in criteria where the field is nested inside an array.
2.4.1
Resolved Issues
-
#1593Arrays on embedded documents now properly atomically update when modified from original version. -
#1592Don't swallow exceptions from index generation in the create_indexes rake task. -
#1589Allow assignment of empty array to HABTM when no documents are yet loaded into memory. -
#1587When a previous value for an array field was an explicit nil, it can now be reset atomically with new values. -
#1585Model#respond_to?returns true now for the setter when allowing dynamic fields. -
#1582Allow nil values to be set in arrays. -
#1580Allow arrays to be set to nil post save, and not just empty. -
#1579Don't call#to_aon individual set field elements in criterion. -
#1576Don't hit database on uniqueness validation if the field getting validated has not changed. -
#1571Aliased fields get all the dirty attribute methods and all getters and setters for both the original name and the alias. (Hans Hasselberg) -
#1568Fallback to development environment with warning when no env configured. -
#1565For fields and foreign keys with non-standard Ruby or database names, use define_method instead of class_eval for creating the accessors and dirty methods. -
#1557Internal strategy class no longer conflicts with models. -
#1551Parent documents now returntrueforModel#changed?if only child (embedded) documents have changed. -
#1547Resetting persisted children from a parent save when new waits until post callbacks, mirroring update functionality. -
#1536Eager loading now happens when callingfirstorlaston a criteria if inclusions are specified.
2.4.0
New Features
-
Ranges can now be passed to
#wherecriteria to create a $gte/$lte query under the covers.Person.where(dob: start_date...end_date) -
Custom serializable fields can now override
#selectionto provide customized serialization for criteria queries. -
#1544Internals useArray.wrapinstead ofto_anow where possible. -
#1511Presence validation now supports localized fields. (Tiago Rafael Godinho) -
#1506Model.setwill now accept false and nil values. (Marten Veldthuis) -
#1505Model.delete_all/destroy_allnow take either a:conditionshash or the attributes directly. -
#1504Model.recursively_embeds_manynow accepts a:cascade_callbacksoption. (Pavel Pravosud) -
#1496Mongoidnow casts strings back to symbols for symbol fields that get saved as strings by another application. -
#1454,#900Associations now have anafter_buildcallback that gets executed after.buildorbuild_methods are called. (Jeffrey Jones, Ryan Townsend) -
#1451Ranges can now be any range value, not just numbers. (aupajo) -
#1448Localization is now used when sorting. (Hans Hasselberg) -
#1422Mongoidraises an error at yaml load if no environment is found. (Tom Stuart) -
#1413$not support added to criteria symbol methods. (Marc Weil) -
#1403Added configuration optionscope_overwrite_exceptionwhich defaults to false for raising an error when defining a named scope with the same name of an existing method. (Christoph Grabo) -
#1388model.add_to_setnow supports adding multiple values and performs an $addToSet with $each under the covers. (Christian Felder) -
#1387AddedModel#cache_keyfor use inRailscaching. (Seivan Heidari) -
#1380CallingModel.find(id) will now properly convert to and from any type based on the type of the _id field. -
#1363Added fallbacks and default support to localized fields, and added ability to get and set all translations at once. -
#1362Aliased fields now properly typecast in criteria. -
#1337Arrayfields, including HABTM many foreign keys now have smarter dirty checking and no longer perform a simple $set if the array has changed. If items have only been added to the array, it performs a $pushAll. If items have only been removed, it performs a $pullAll. If both additions and removals have occurred it performs a $set to avoid conflicting mods.
Resolved Issues
-
Calling
Document#as_documenton a frozen document on Rubinius returns the attributes instead of nil. -
#1554Split application of default values into proc/non-procs, where non-procs get executed immediately during instantiation, and procs get executed after all other values are set. -
#1553Combinations of adding and removing values from an array use a $set on the current contents of the array, not the new values. -
#1546Dirty changes should be returned in a hash with indifferent access. -
#1542Eager loading now respects the options (ie skip, limit) provided to the criteria when fetch the associations. -
#1530Don't duplicate added values to arrays via dirty tracking if the array is a foreign key field. -
#1529Callingunscopedon relational associations now works properly. -
#1524Allow access to relations in overridden field setters by pre-setting foreign key default values. -
#1523Allow disabling of observers viadisable. (Jonas Schneider) -
#1522Fixed create indexes rake task forRails3.2. (Gray Manley) -
#1517Fix Mongoid documents to properly work with RSpec's stub_model. (Tiago Rafael Godinho) -
#1516Don't duplicate relational many documents on bind. -
#1515Mongoidno longer attempts to serialize custom fields on complex criteria by default. -
#1503Has many relation substitution now handles any kind of mix of existing and new docs. -
#1502Nested attributes on embedded documents respects if the child is paranoid. -
#1497Use provided message on failing uniqueness validation. (Justin Etheredge) -
#1491Return nil when no default set on localized fields. (Tiago Rafael Godinho) -
#1483Sending module includes at runtime which add new fields to a parent document, also have the fields added to subclasses. -
#1482Applying new sorting options does not merge into previously chained criteria. (Gerad Suyderhoud) -
#1481Fix invalid query when accessing many-to-many relations before defaults are set. -
#1480Mongoid's internal serialized field types renamespaced to Internal in order to not conflict with ruby core classes in custom serializable types. -
#1479Don't duplicate ids on many-to-many when using create or create! -
#1469When extract_id returns nil, get the document out of the identity map by the criteria selector. -
#1467Defining a field named metadata now properly raises an invalid field error. -
#1463Batch insert consumers are now scoped to collection to avoid persistence of documents to other collections in callbacks going to the wrong place. -
#1462Assigning has many relations via nested attributes*_attributes=does not autosave the relation. -
#1461Fixed serialization of foreign key fields in complex criteria not to escape the entire hash. -
#1458Versioning no longer skips fields that have been protected from mass assignment. -
#1455,#1456Calling destroy on any document now temporarily marks it as flagged for destroy until the operation is complete. (Nader Akhnoukh) -
#1453Model#to_keyshould return a value when the document is destroyed. -
#1449New documents no longer get persisted when replaced on a has one as a side effect. (jasonsydes) -
#1439embedded? should return true when relation defined as cyclic. -
#1433Polymorphic nested attributes for embedded and relational 1-1 now update properly. -
#1426Frozen documents can now be cloned. (aagrawal2001) -
#1382Raise proper error when creating indexes via rake task if index definition is incorrect. (Mathieu Ravaux) -
#1381,#1371The identity map now functions properly with inherited documents. (Paul Canavese) -
#1370Split concat on embedded arrays into its own method to handle the batch processing due to after callback run execution issues. -
#1366Arrayand hash values now get deep copied for dirty tracking. -
#1359Provide ability to not have default scope applied to all named scopes via using lambdas. -
#1333Fixed errors with custom types that exist in namespaces. (Peter Gumeson) -
#1259Default values are treated as dirty if they differ from the database state. -
#1255Ensure embedded documents respect the defined default scope.
2.3.4
-
#1445Prevent duplicate documents in the loaded array on the target enumerable for relational associations. -
#1442When using create_ methods for has one relations, the appropriate destructive methods now get called when replacing an existing document. -
#1431Enumerable context should add to the loaded array post yield, so that methods like #any? that short circuit based on the value of the block dont falsely have extra documents. -
#1418Documents being loaded from the database for revision purposes no longer get placed in the identity map. -
#1399Allow conversion of strings to integers in foreign keys where the id is defined as an int. -
#1397Don't add default sorting criteria on first if they sort criteria already exists. -
#1394Fix exists? to work when count is greater than 1. (Nick Hoffman) -
#1392Return 0 on aggregation functions where field is nonexistent. -
#1391Uniqueness validation now works properly on embedded documents that are using primary key definitions. -
#1390When _type field is lower case class camelize before constantizing. -
#1383Fix cast on read for serializable fields that are subclassed. -
#1357Delayed atomic sets from update_attributes on embedded documents multiple levels deep now properly persist. -
#1326Ensure base document on HABTM gets its keys saved after saving a newly build child document. -
#1301Don't overwrite base metadata on embedded in relations if already set. -
#1221HABTM with inverse nil is allowed again on embedded documents. -
#1208Don't auto-persist child documents via the setter when setting from an embedded_in. -
#791Root document updates its timestamps when only embedded documents have changed.
2.3.3
Resolved Issues
-
#1386Lowered mongo/bson dependency to 1.3 -
#1377Fix aggregation functions to properly handle nil or undefined values. (Maxime Garcia) -
#1373Warn if a scope overrides another scope. -
#1372Never persist when binding inside of a read attribute for validation. -
#1364Fixed reloading of documents with non bson object id ids. -
#1360Fixed performance of Mongoid's observer instantiation by hooking into Active Support's load hooks, a la AR. -
#1358Fixed type error on many to many synchronization when inverse_of is set to nil. -
#1356$in criteria can now be chained to non-complex criteria on the same key without error. -
#1350,#1351Fixed errors in the string conversions of double quotes and tilde when parametrizing keys. -
#1349Mongoiddocuments should not blow up when including Enumerable. (Jonas Nicklas)
2.3.2
Resolved Issues
-
#1347Fix embedded matchers when provided a hash value that does not have a modifier as a key. -
#1346Dup default sorting criteria when calling first/last on a criteria. -
#1343When passing no arguments toCriteria#all_ofreturn all documents. (Chris Leishman) -
#1339Ensure destroy callbacks are run on cascadable children when deleting via nested attributes. -
#1324Settinginverse_of: nilon a many-to-many referencing the same class returns nil for the inverse foreign key. -
#1323Allow both strings and symbols as ids in the attributes array for nested attributes. (Michael Wood) -
#1312Setting a logger on the config now accepts anything that quacks like a logger. -
#1297Don't hit the database when accessing relations if the base is new. -
#1239Allow appending of referenced relations in create blocks, post default set. -
#1236Ensure all models are loaded in rake tasks, so even in threadsafe mode all indexes can be created. -
#736Calling#reloadon embedded documents now works properly.
2.3.1
Resolved Issues
-
#1338Calling#findon a scope or relation checks that the document in the identity map actually matches other scope parameters. -
#1321HABTM no longer allows duplicate entries or keys, instead of the previous inconsistencies. -
#1320Fixed errors in perf benchmark. -
#1316Added a separate Rake task "db:mongoid:drop" soMongoidand AR can coexist. (Daniel Vartanov) -
#1311Fix issue with custom field serialization inheriting from hash. -
#1310The referenced many enumerable target no longer duplicates loaded and added documents when the identity map is enabled. -
#1295Fixed having multiple includes only execute the eager loading of the first. -
#1287Fixed max versions limitation with versioning. -
#1277attribute_will_change! properly flags the attribute even if no change occurred. -
#1063Paranoid documents properly run destroy callbacks on soft destroy. -
#1061Raise::Mongoid::Errors::InvalidTimewhen time serialization fails. -
#1002Check for legal bson ids when attempting conversion. -
#920Allow relations to be named target. -
#905Return normalized class name in metadata if string was defined with a prefixed ::. -
#861accepts_nested_attributes_for is no longer needed to set embedded documents via a hash or array of hashes directly. -
#857Fixed cascading of dependent relations when base document is paranoid. -
#768Fixed class_attribute definitions module wide. -
#408Embedded documents can now be soft deleted viaMongoid::Paranoia.
2.3.0
New Features
-
Mongoidnow supports basic localized fields, storing them under the covers as a hash of locale => value pairs.field :name, localize: true -
#1275For applications that default safe mode to true, you can now tell a single operation to persist without safe mode via #unsafely:person.unsafely.save,Person.unsafely.create. (Matt Sanders) -
#1256Mongoidnow can create indexes for models inRailsengines. (Caio Filipini) -
#1228Allow pre formatting of composite keys by passing a block to#key. (Ben Hundley) -
#1222Scoped mass assignment is now supported. (Andrew Shaydurov) -
#1196Timestamps can now be turned off on a call-by-call basis via the use of #timeless:person.timeless.save,Person.timeless.create(:title => "Sir"). -
#1103Allow developers to create their own custom complex criteria. (Ryan Ong) -
Mongoidnow includes all defined fields inserializable_hashandto_jsonresults even if the fields have no values to make serialized documents easier to use by ActiveResource clients. -
Support for MongoDB's $and operator is now available in the form of:
Criteria#all_of(*args)where args is multiple hash expressions. -
#1250,#1058Embedded documents now can have their callbacks fired on a parent save by setting:cascade_callbacks => trueon the relation. (pyromanic, Paul Rosania, Jak Charlton)
Major Changes
-
Mongoidnow depends on Active Model 3.1 and higher. -
Mongoidnow depends on the Mongo Ruby Driver 1.4 and higher. -
Mongoidrequires MongoDB 2.0.0 and higher.
Resolved Issues
-
#1308Fixed scoping of HABTM finds. -
#1300Namespaced models should handle recursive embedding properly. -
#1299Self referenced documents with versioning no longer fail when inverse_of is not defined on all relations. -
#1296Renamed internal building method to _building. -
#1288,#1289_id and updated_at should not be part of versioned attributes. -
#1273Mongoid.preload_modelsnow checks if preload configuration option is set, where Mongoid.load_models always loads everything. (Ryan McGeary) -
#1244Has one relations now adhere to default dependant behavior. -
#1225Fixed delayed persistence of embedded documents via $set. -
#1166Don't load config in Railtie if no env variables defined. (Terence Lee) -
#1052alias_attributenow works again as expected. -
#939Apply default attributes when upcasting via#becomes. (Christos Pappas) -
#932Fixed casting of integer fields with leading zeros. -
#948Reset version number on clone if versions existed. -
#763Don't merge $in criteria arrays when chaining named scopes. -
#730Existing models that have relations added post persistence of originals can now have new relations added with no migrations. -
#726Embedded documents with compound keys not validate uniqueness correctly. -
#582Cyclic non embedded relations now validate uniqueness correctly. -
#484Validates uniqueness with multiple scopes of all types now work properly. -
Deleting versions created with
Mongoid::Versioningno longer fires off dependent cascading on relations.
2.2.5
- This was a small patch release to address 2.2.x Heroku errors during asset compilation.
2.2.4
-
#1377Fix aggregation functions to properly handle nil or undefined values. (Maxime Garcia) -
#1373Warn if a scope overrides another scope. -
#1372Never persist when binding inside of a read attribute for validation. -
#1358Fixed type error on many to many synchronization when inverse_of is set to nil. -
#1356$in criteria can now be chained to non-complex criteria on the same key without error. -
#1350,#1351Fixed errors in the string conversions of double quotes and tilde when parameterizing keys. -
#1349Mongoiddocuments should not blow up when including Enumerable. (Jonas Nicklas)
2.2.3
-
#1295Fixed having multiple includes only execute the eager loading of the first. -
#1225Fixed delayed persistence of embedded documents via $set. -
#1002Fix BSON object id conversion to check if legal first.
2.2.2
- This release removes the restriction of a dependency on 1.3.x of the mongo ruby driver. Users may now use 1.3.x through 1.4.x.
2.2.1
Resolved Issues
-
#1210,#517Allow embedded document relation queries to use dot notation. (Scott Ellard) -
#1198Enumerable target should use criteria count if loaded has no docs. -
#1164Get rid of remaining no method in_memory errors. -
#1070Allow custom field serializers to have their own constructors. -
#1176Allow access to parent documents from embedded docs in after_destroy callbacks. -
#1191Context group methods (min, max, sum) no longer return NaN but instead return nil if field doesn't exist or have values. -
#1193,#1271Always return Integers for integer fields with .000 precisions, not floats. -
#1199Fixed performance issues of hash and array field access when reading multiple times. -
#1218Fixed issues with relations referencing models with integer foreign keys. -
#1219Fixed various conflicting modifications issues when pushing and pulling from the same embedded document in a single call. -
#1220Metadata should not get overwritten by nil on binding. -
#1231Renamed Mongoid's atomic set class to Sets to avoid conflicts with Ruby's native Set after document inclusion. -
#1232Fix access to related models during before_destroy callbacks when cascading. -
#1234Fixed HABTM foreign key synchronization issues when destroying documents. -
#1243Polymorphic relations dont convert to object ids when querying if the ids are defined as strings. -
#1247ForceModel.firstto sort by ascending id to guarantee first document. -
#1248Added#unscopedto embedded many relations. -
#1249Destroy flags in nested attributes now actually destroy the document for has_many instead of just breaking the relation. -
#1272Don't modify configuration options in place when creating replica set connections.
2.2.0
New Features
-
Mongoidnow contains eager loading in the form ofCriteria#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: truein yourmongoid.yml. Ex:Person.where(title: "Sir").includes(:posts, :game) -
Relations can now take a module as a value to the
:extendoption. (Roman Shterenzon) -
Capped collections can be created by passing the options to the
#store_inmacro:Person.store_in :people, capped: true, max: 1000000 -
Mongoid::Collectionnow supportscollection.find_and_modify -
Document#has_attribute?now aliases toDocument#attribute_present? -
#930You can now turn off theMongoidlogger via the mongoid.yml by doinglogger: false -
#909We now raise a::Mongoid::Errors::Callbackexception if persisting with a bang method and a callback returns false, instead of the uninformative validations error from before.
Major Changes
-
#1173has_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 behavior should occur. :delete and :destroy will behave as before, :nullify and no option specified will both nullify the old documents without deleting. -
#1142,#767Embedded relations no longer immediately persist atomically when accessed via a parent attributes set. This includes nested attributes setting andattributes=orwrite_attributes. The child changes then remain dirty and atomically update when save is called on them or the parent document.
Resolved Issues
-
#1190Fixed the gemspec errors due to changing README and CHANGELOG to markdown. -
#1180,#1084,#955Mongoidnow checks the field types rather than if the name contains/id/when trying to convert to object ids on criteria. -
#1176Enumerable targets should always return the in memory documents first, when calling#first -
#1175Make sure both sides of many to many relations are in sync during a create. -
#1172Referenced enumerable relations now properly handle#to_json(Daniel Doubrovkine) -
#1040Increased performance of class load times by removing all delegate calls to self.class.
2.1.9
Resolved Issues
-
#1159Fixed build blocks not to cancel out each other when nested. -
#1154Don't delete many-to-many documents on empty array set. -
#1153Retain parent document reference in after callbacks. -
#1151Fix associated validation infinite loop on self referencing documents. -
#1150Validates associated onbelongs_toisfalseby default. -
#1149Fixed metadata setting onbelongs_torelations. -
#1145Metadata inverse should returnnilifinverse_ofwas set asnil. -
#1139Enumerable targets now quack like arrays. -
#1136Settingbelongs_toparent tonilno longer deletes the parent. -
#1120Don't callin_memoryon relations if they don't respond to it. -
#1075Setselfin default procs to the document instance. -
#1072Writing attributes for nested documents can take a hash or array of hashes. -
#990Embedded documents can use a singleembedded_inwith multiple parent definitions.
2.1.8
Resolved Issues
-
#1148Fixedrespond_to?on all relations to return properly. -
#1146Added back theMongoiddestructive fields check when defining fields. -
#1141Fixed conversions ofnilvalues in criteria. -
#1131Verified Mongoid/Kaminari paginating correctly. -
#1105Fixed atomic update consumer to be scoped to class. -
#1075selfin default lambdas and procs now references the document instance. -
#740Removedembedded_object_idconfiguration parameter. -
#661Fixed metadata caching on embedded documents. -
#595Fixed relation reload flagging. -
#410Moving documents from one relation to another now works as expected.
2.1.7
This was a specific release to fix MRI 1.8.7 breakages introduced by 2.1.6.
2.1.6
Resolved Issues
-
#1126Fix setting of relations with other relation proxies. -
#1122Hashand array fields now properly flag as dirty on access and change. -
#656Fixed reload breaking relations on unsetting of already loaded associations. -
#647Prefer#unsetto#remove_attributefor removing values. -
#290Verify pushes into deeply embedded documents.
2.1.5
Resolved Issues
-
#1116Embedded children retain reference to parent in destroy callbacks. -
#1110,#1115Don't memoize metadata related helpers on documents. -
#1112db:create_indexesno longer indexes subclasses multiple times. -
#1111,#1098Don't set_idin$setoperations. -
#1007Update attribute properly tracks array changes.
2.1.4
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.
2.1.3
Resolved Issues
-
#1109Fixed validations not loading one to ones into memory. -
#1107Mongoidno longer wants requiredmongoid/railtieinapplication.rb. -
#1102Fixed nested attributes deletion. -
#1097Reload now runsafter_initializecallbacks. -
#1079Embeds many no longer duplicates documents. -
#1078Fixed array criteria matching on embedded documents. -
#1028Implement scoped on one-to-many and many-to-many relations. -
#988Many-to-many clear no longer deletes the child documents. -
#977Autosaving relations works also through nested attributes. -
#972Recursive embedding now handles namespacing on generated names. -
#943Don't overrideDocument#attributes. -
#893Verify count is not caching on many to many relations. -
#815Verifyafter_initializeis run in the correct place. -
#793Verifyany_ofscopes chain properly with any other scope. -
#776Fixed mongoid case quality when dealing with subclasses. -
#747Fixed complex criteria using its keys to render its string value. -
#721#safelynow properly raises validation errors when they occur.
2.1.2
Resolved Issues
-
#1082Aliassizeandlengthtocounton criteria. (Adam Greene) -
#1044When multiple relations are defined for the same class, always return the default inverse first ifinverse_ofis not defined. -
#710Nested attributes accept bothidand_idin hashes or arrays. -
#1047Ignorenilvalues passed toembeds_manpushes and substitution. (Derick Bailey)
2.1.1
Resolved Issues
-
#1021,#719Many to many relations dont trigger extra database queries when pushing new documents. -
#607Callingcreateon large associations does not load the entire relation. -
#1064Mongoid::Paranoiashould respectunscopedandscoped. -
#1026model#update_attributenow can update booleans tofalse. -
#618Crack XML library breaksMongoidby adding#attributesmethod to theStringclass. (Stephen McGinty)
2.1.0
Major Changes
-
Mongoidnow requires MongoDB 1.8.x in order to properly support the#bitand#renameatomic 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
-
Mongoidmodel preloading in development mode now defaults tofalse. -
:autosave => trueon relational associations now saves on update as well as create. -
Mongoidnow has an identity map for simplefind_by_idqueries. See the website for documentation.
New Features
-
#1067Fields now accept a:versionedattribute to be able to disable what fields are versioned withMongoid::Versioning. (Jim Benton) -
#587Added order preference to many and many to many associations. (Gregory Man) -
Added ability to chain
order_bystatements. (Gregory Man) -
#961Allow arbitraryMongo::Connectionoptions to pass throughMongoid::Config::Databaseobject. (Morgan Nelson) -
Enable
autosavefor 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)
Resolved Issues
-
#974Fixattribute_present?to work correctly then attribute value isfalse, thanks to @nickhoffman. (Gregory Man) -
#960create indexes rake task is not recognizing a lot of mongoid models because it has problems guessing their model names from filenames. (Tobias Schlottke) -
#874Deleting from a M-M reference is one-sided. (nickhoffman, davekrupinski) -
Replace deprecated
class_inheritable_hashdropped inRails3.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)
-
#914Querying embedded documents with$orselector. (Max Golovnia) -
#514Fix marshaling of documents with relation extensions. (Chris Griego) -
Metadata#extensionnow returns aModule, instead of aProc, when an extension is defined. -
#837Whenallow_dynamic_fieldsis set tofalseand loading an embedded document with an unrecognized field, an exception is raised. -
#963Initializing array of embedded documents via hash regressed (Chris Griego, Morgan Nelson) -
Mongoid::Config.resetresets the options to their default values. -
Mongoid::Fields.defaultsis memoized for faster instantiation of models.