Use Date#all_day in DirectMessage.today

The method `Date#all_day` was added in Rails 5.1, and returns the same
interval we were using while it makes the code simple.
This commit is contained in:
Javi Martín
2019-06-21 00:28:57 +02:00
parent 4e76f90afd
commit 3ba8b05cbb

View File

@@ -8,7 +8,7 @@ class DirectMessage < ApplicationRecord
validates :receiver, presence: true validates :receiver, presence: true
validate :max_per_day validate :max_per_day
scope :today, lambda { where(created_at: Date.current.beginning_of_day..Date.current.end_of_day) } scope :today, lambda { where(created_at: Date.current.all_day) }
def max_per_day def max_per_day
return if errors.any? return if errors.any?