【发布时间】:2014-05-19 09:28:19
【问题描述】:
我有一个@parent 模型,其中有很多@kids 模型
@parent = Parent.find(par_id)
@kid = @parent.kids.first
@parent.update_attributes(params) #change parent's name
@kid.parent 与 @parent 不同,尽管 @kid.parent == @parent
唯一的区别是 Parent.name 不同
这会导致孩子的视图使用旧的父名称呈现错误 在视图中:
<%= @kid.parent.name %> #=> this renders the old name and not the newly updated on
有没有办法刷新关联或模型?
【问题讨论】:
标签: ruby-on-rails caching ruby-on-rails-4 model model-associations