lib/mongoid/factory.rb in mongoid-2.3.3 vs lib/mongoid/factory.rb in mongoid-2.3.4

- old
+ new

@@ -34,9 +34,13 @@ # @param [ Hash ] attributes The document attributes. # # @return [ Document ] The instantiated document. def from_db(klass, attributes = {}) type = attributes["_type"] - type.blank? ? klass.instantiate(attributes) : type.constantize.instantiate(attributes) + if type.blank? + klass.instantiate(attributes) + else + type.camelize.constantize.instantiate(attributes) + end end end end