Ruby on Rails - Date Comparison -


I am trying to compare dates for app in train I have tried this link but it is my wish Suppose I have a filter according to the dates, I am doing

& lt;% jobs = @ user.jobs.where (: curr_date = & gt; (date .today))%>

Here, curr_date is a "date" attribute I picked.

This code works for those entries which is today's date, but if I want all entries from today's date and a week ago, what should I do?

Thanax! :)

You can use just

  jobs = @user Jobs.where (: curr_date = & gt; (DateTime.now..1.week.ago)) Updated   

DateTime.now Or you can also use it Date.Today.to_time otherwise date and time

Comments