I have a candidate which has_many votes.
I am trying to get the votes of a candidate that were created in the current month?
@candidate.votes.from_this_m
scope :this_month, -> { where(created_at: Time.zone.now.beginning_of_month..Time.zone.now.end_of_month) }
and you can call the scope:
Model.this_month