badar_madeena/app/models/expense.rb

9 lines
363 B
Ruby

class Expense < ApplicationRecord
scope :today, -> { where(created_at: Time.current.all_day) }
scope :this_week, -> { where(created_at: Time.current.all_week) }
scope :this_month, -> { where(created_at: Time.current.all_month) }
validates :amount, presence: true, numericality: { greater_than_or_equal_to: 0 }
validates :date, presence: true
end