-
Type: Task
-
Resolution: Done
-
Affects Version/s: None
-
Component/s: None
Hey guys,
Been banging my head on the keyboard for over an hour with this one - I feel like it's my stupidity, but just not seeing it..
I've simplified this code a bit, but the process is the same.
class Foo include Mongoid::Document has_many :bars def add_bar!(name, metadata = { }) bars.create! :name => name, :metadata => metadata end end class Bar include Mongoid::Document belongs_to :foo field :name, :type => String field :metadata, :type => Hash end f = Foo.create! b = f.add_bar!("oh hai", { :something => "blah" }) # at this point, b.metadata looks good, BUT Bar.find(b.id).metadata.nil? # returns true
I don't understand how the create! can report that everything has saved OK, yet the Hash data clearly has not been saved?
Many TIA.
Rob