Skip to content
Snippets Groups Projects
Commit 910fdbaf authored by Mateus Rambo Strey's avatar Mateus Rambo Strey
Browse files

fix view model

parent f0dfaac6
No related branches found
No related tags found
No related merge requests found
......@@ -2,14 +2,14 @@ class View < ActiveRecord::Base
belongs_to :viewable, polymorphic: true, counter_cache: true
belongs_to :user
scope :last, ->(user) { where(user: user).order('created_at DESC').limit(1).first }
scope :created_last, ->(user) { where(user: user).order('created_at DESC').limit(1).first }
before_create :current_time_greater_than_last
private
def current_time_greater_than_last
last_view = viewable.views.last(user)
last_view = viewable.views.created_last(user)
unless last_view.blank?
return false if Time.now < (last_view.created_at + 1.days)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment