I have an ActiveRecord model that has a date attribute. Is it possible to utilize that date attribute to find by Year, Day and Month:
Model.find_by_year(201
Another short scope as below:
class Leave scope :by_year, -> (year) { where(date: Date.new(year).beginning_of_year..Date.new(year).end_of_year) } end
Call the scope:
Leave.by_year(2020)