我遇到的问题与更新嵌套属性的引用文件不被坚持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