Make Comment find_since_last_login scope robust against nil value
to fix production ArgumentError: bad value for range. Fixes #807.
This commit is contained in:
parent
55ab8a8e8f
commit
a6c89351c5
2 changed files with 15 additions and 1 deletions
|
|
@ -41,7 +41,11 @@ class Comment < ActiveRecord::Base
|
|||
}
|
||||
|
||||
scope :find_since_last_login, lambda { |user|
|
||||
where(created_at: (user.last_sign_in_at..Time.now)).order(created_at: :desc)
|
||||
if user.last_sign_in_at
|
||||
where(created_at: (user.last_sign_in_at..Time.now)).order(created_at: :desc)
|
||||
else
|
||||
none
|
||||
end
|
||||
}
|
||||
# Helper class method to look up a commentable object
|
||||
# given the commentable class name and id
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue