Ruby on rails 刷新ActiveRecord结果
如何以“rails方式”刷新ActiveRecord结果?例如:Ruby on rails 刷新ActiveRecord结果,ruby-on-rails,activerecord,Ruby On Rails,Activerecord,如何以“rails方式”刷新ActiveRecord结果?例如: stuff = Stuff.find(:id) a = stuff.x # a = 3 (at this time field value in database stuff.x changed to 7 ) a = stuff.x # a = 3 but I need here 7 是否可以执行stuff.refresh\u data之类的操作来重新执行查询?您可以使用重新加载。在您的情况下,您将编写内容。重新加载 以
stuff = Stuff.find(:id)
a = stuff.x # a = 3
(at this time field value in database stuff.x changed to 7 )
a = stuff.x # a = 3 but I need here 7
是否可以执行stuff.refresh\u data之类的操作来重新执行查询?您可以使用
重新加载
。在您的情况下,您将编写内容。重新加载
以下是花了3个小时调试为什么我的愚蠢对象没有更新的原因。。。找到了这个。非常感谢。