0 votes
1 view
in AWS by (18.2k points)

I have a rails application where it displays active EVENTS (Events on or after today).

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

It is coming fine on local. But on the production server, the query is taking the Date of deployment for comparison.

This is the log

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 the check from console on production, it is showing correctly

 1.9.3-p448 :001 > Date.today

     => Fri, 19 Sep 2014

The server is on AWS EC2

1 Answer

0 votes
by (42.4k points)

Try putting it in a lambda:

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

Probably Date.today is being evaluated at the time when the code is loaded(i.e. deployed).

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...