为什么我的示波器被缓存了? [英] Why is my scope getting cached?
本文介绍了为什么我的示波器被缓存了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的范围如下:
scope :top, order('score DESC')
在我的控制器中使用如下:
It's used as follows in my controller:
def top
@users = User.top
render "list"
end
现在,似乎毫无缘由地缓存了该范围。如果我加载首页,添加一个用户并重新加载,则该用户不会出现在列表中。
Now, it seems that this scope is getting cached for no reason at all. If I load the top page, add a user and reload it, the user does not appear in the list.
但是,如果我这样做:
def top
@users = User.order('score DESC')
render "list"
end
结果不会被缓存。这是怎么回事我正在使用Ruby 2.0.0和Rails 4.0.0
The results don't get cached. What is happening here? I'm using Ruby 2.0.0 and Rails 4.0.0
推荐答案
发现了问题所在!范围应该定义如下:
Found what the problem is! The scope should have been defined as follows:
scope :top, order: 'score DESC'
这篇关于为什么我的示波器被缓存了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文