Building a Task Manager and need help limiting my Task model to only tasks that are due today I've tried comparing my task's duedate to Date.now but doesn't seem to be working.
This is my schema
create_table "tasks", force: :cascade do |t|
t.string "title"
t.string "description"
t.datetime "duedate"
t.boolean "completed"
t.datetime "created_at", precision: 6, null: false
t.datetime "updated_at", precision: 6, null: false
end
This is my Task model.
class Task < ApplicationRecord
#use scope on Task model to mark overdue Tasks if the present date is greater than duedate.
scope :overdue, -> { where("duedate < ?", Time.now) }
scope :due_today, ->{ where("duedate = ?", Date.now) }
def overdue?
duedate < Time.now
end
def due_today?
duedate = Date.now
end
end