From 078e05666ec116632b7a3ee9f9cd336e1b4d70fa Mon Sep 17 00:00:00 2001 From: Israel Barreto Sant'Anna <ibsa14@inf.ufpr.br> Date: Tue, 4 Apr 2017 11:19:17 -0300 Subject: [PATCH] Ignore activity for download without user Signed-off-by: Israel Barreto Sant'Anna <ibsa14@inf.ufpr.br> --- app/models/download.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/download.rb b/app/models/download.rb index 9812839a..8b5dae1a 100644 --- a/app/models/download.rb +++ b/app/models/download.rb @@ -17,9 +17,15 @@ class Download < ApplicationRecord belongs_to :downloadable, polymorphic: true, counter_cache: true belongs_to :user, optional: true - validates_presence_of :ip, :downloadable + validates :ip, :downloadable, presence: true def recipient downloadable end + + private + + def new_create_activity + new_activity(:create) unless user.nil? + end end -- GitLab