【发布时间】:2011-06-10 03:20:16
【问题描述】:
我遇到了一个更新嵌套属性的问题,引用文档没有被持久化
> 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/update_attributes/save all 不会持久化嵌套的更改。
我在用户模型中声明了attr_accessible :profile_attributes。
当父文档已经被持久化时,嵌套属性需要什么来持久化?
【问题讨论】:
标签: ruby-on-rails mongoid persistence