Use Time.current converted to Date by the database DirectMessage today scope
Why: * Database stores created_at as timestamp with the timezone, so when comparing DATE(created_at) to something we have to convert it to DATE as well with the postresql native function, but using Time.current instead of Date.current to take into account the user timezone
This commit is contained in:
@@ -8,7 +8,7 @@ class DirectMessage < ActiveRecord::Base
|
|||||||
validates :receiver, presence: true
|
validates :receiver, presence: true
|
||||||
validate :max_per_day
|
validate :max_per_day
|
||||||
|
|
||||||
scope :today, lambda { where('DATE(created_at) = ?', Date.current) }
|
scope :today, lambda { where('DATE(created_at) = DATE(?)', Time.current) }
|
||||||
|
|
||||||
def max_per_day
|
def max_per_day
|
||||||
return if errors.any?
|
return if errors.any?
|
||||||
|
|||||||
Reference in New Issue
Block a user