Back

Explore Courses Blog Tutorials Interview Questions
0 votes
3 views
in AWS by (19.1k 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 (44.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).

Related questions

Want to get 50% Hike on your Salary?

Learn how we helped 50,000+ professionals like you !

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

Browse Categories

...