There are two classes:
class Person include Mongoid::Document field :name embeds_many :addresses end class Address include Mongoid::Document field :city field :street validates_presence_of :city, :street end
We see that we checked city and street .
But see the following code:
person = Person.new person.addresses << Address.new person.save
And we use mongo to directly view the database:
$mongo > use the_db > db.people.find() {"_id":"xxxxx", "addresses":[{"_id":"xxxxx"}]}
Address entered. This means that validates_presence_of :city, :street in Address not working.
Did I miss something? Or is there a bug in Mongoid?
source share