我遇到的問題與更新嵌套屬性的引用文件不被堅持mongoid:更新嵌套屬性
> u = User.first
=> #<User...
> u.changes
=> {}
> u.profile.changes
=> {}
> u.attributes = {:profile_attributes => {:weight => 8}}
=> {:profile_attributes=>{:weight=>8}}
> u.changes
=> {}
> u.profile.changes
=> {"weight"=>[14.0, 8.0]}
> u.update
=> true
> u.shipping_profile.changes
=> {"weight"=>[14.0, 8.0]}
更新/ update_attributes方法/保存所有不持久嵌套的變化。 我在用戶模型中聲明瞭attr_accessible :profile_attributes
。
嵌套屬性在父文檔已保存時需要保留什麼?
是的,我也有這條線。忘了包括那個。 – brewster 2011-06-10 17:11:01