I'm trying to make a feed page where users can see the popular posts and the posts of whom they followed. This what I tried (but failed):
@popularPosts = Post.where(cached_votes_score > '2')
returning an error.
undefined local variable or method `cached_votes_score' for #<PagesController:0x007fa2ae08f630> Did you mean? cache_store
Any thought on this?
What you want is done:
Post.where('cached_votes_score > 2')
What you where trying to do was interpreted as trying to call a method cached_votes_score in the controller and comparing if its returned value is greater than '2'
.
Rails doesn't have a Railsism to do greater than comparisons, so you do a SQL segment to accomplish it.