-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
Labels:None
I have two models:
class Book
include Mongoid::Document
field :title
field :author
embeds_many :chapters
validates_presence_of :title
end
=========================
class Chapter
include Mongoid::Document
field :name
field :content
validates_presence_of :name
embedded_in :book,:inverse_of => :chapters
end
the bug is when I do this:
p = Book.new(:title => "New Title", :author => "New Author")
p.chapters << Chapter.new
p.save
true
in other words, apparently, Mongoid don't work like ActiveRecord or
MongoMapper that does not allow saves documents if their child
classes are not valid..
beyond that, the AR and MongoMapper throw the validation errors to
the parent class errors... thats allow to show the erros using the
same form_for
thanks!