M
M
Max2015-11-28 15:52:08
Ruby on Rails
Max, 2015-11-28 15:52:08

How to display data from a table added in the last 3 days in rails?

Hello, please help me sort this.
There is a database of hospital patients, I want to display only those who have been admitted in the last 3 days.
For the experiment, I tried to do something like this in the console:
user = User.where(enter_date: 2015-11-27)
But on the output, just subtraction actions occur and an empty array is returned)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
N. Bekseitov, 2015-11-28
@maxprof

user = User.where("enter_date >= ?", 3.days.ago)

T
TyzhSysAdmin, 2015-11-28
@POS_troi

You need to add quotes.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question