Rails Date.today reflects server deployment date

I have a rails app that displays active EVENTS (Events that happened today or since).

scope :active, where("event_date >= ?", Date.today).order("event_date ASC")

It is doing well locally. But on the production server, the query takes the deployment date for comparison.

This is a magazine

SELECT "events".* FROM "events" WHERE "events"."school_id" = 32 AND (roster_id in (45) or roster_id IS NULL) AND (event_date >= '2014-09-18') ORDER BY event_date ASC

But if you check the console in production it displays correctly

 1.9.3-p448 :001 > Date.today
     => Fri, 19 Sep 2014

      

The server is on AWS EC2

Any help is greatly appreciated.

+3


source to share


1 answer


Try putting it in a lambda:

scope :active, -> { where("event_date >= ?", Date.today).order("event_date ASC") }

      



Probably Date.today

evaluated at code load time (i.e. deployed).

+6


source







All Articles