I have a scope that looks as follows:
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.
If I do this however:
def top
@users = User.order('score DESC')
render "list"
end
The results don't get cached. What is happening here? I'm using Ruby 2.0.0 and Rails 4.0.0
I think if you use a lambda, then it should not get cached:
scope :top, lambda { order('score DESC') }
But then again, I'm not that familiar with the new Rails 4 scope caching.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With