Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 刷新ActiveRecord结果_Ruby On Rails_Activerecord - Fatal编程技术网

Ruby on 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之类的操作来重新执行查询?您可以使用重新加载。在您的情况下,您将编写内容。重新加载 以

如何以“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之类的操作来重新执行查询?

您可以使用
重新加载
。在您的情况下,您将编写
内容。重新加载


以下是花了3个小时调试为什么我的愚蠢对象没有更新的原因。

。。找到了这个。非常感谢。