I am coming up with a very weird problem with my app running on production.
I have the following table called Qrtable and it contains 144 records, each one with code field and time field incrementing by 10minutes.
I then have this scope
scope :current, where("time > ? and time <= ?", Time.now-14.minutes, Time.now+5.minutes)
What this scope does is to collect the records within the time range and it returns the first and last record. It either returns 1 or 2 records. Every 5 or so minutes the records it has changes.
On my view i am just printing what the first and last records are as so.
="#{Qrtable.current.last.code} for time #{Qrtable.current.first.code}"
So now this is what happens. I have this running as development environment on my laptop. Every 5 or so minutes i refresh the page the codes change. But my production is running on a hosted server and when i refresh the page, the codes dont change.
I also noticed that when i do a cap deploy this restarts the server and the codes update for the first time but then after that my scope doesn't change as i refresh the page. Just wondering if anyone has any idea or has come across this before.
I have tried refreshing Apache multiple times.
It won't. It's evaluated when the class is evaluated. Use:
scope :current, lambda {where("time > ? and time <= ?", Time.now-14.minutes, Time.now+5.minutes)}