-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
-
None
Hi everybody,
I have the following models:
class Jorge include Mongoid::Document field :title, :type => String embeds_many :tadeus accepts_nested_attributes_for :tadeus, :allow_destroy => true validates_presence_of :title end class Tadeu include Mongoid::Document field :title, :type => String embedded_in :jorge end
And besides that, I create the following objects:
j = Jorge.new
j.tadeus << Tadeu.new
j.title = "pedra sobre pedra"
j.save
And my object, of course, is valid.
j.reload
puts j.valid? # true
Now, I'll clean title attribute and after that I'll update
Unable to find source-code formatter for language: tadeus_attributes```. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
:
ruby
j.title = nil
j.update_attributes :tadeus_attributes => {"0" => {:_id => j.tadeus.first.id, :_destroy => true}}
Now, my object is invalid, of course:
ruby
puts j.valid? # true
And the problem is here. Even my Jorge object still invalid, the "tadeus" relation are empty:
ruby
puts j.tadeus.inspect # []
`
Is it a bug, isn it?