From 5d5380a79a2e21e05619d03f4bbb6cca4ac957f3 Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Sun, 15 Mar 2015 12:40:51 -0300 Subject: [PATCH] return empty array when nil profile is passed as parameter --- app/models/article.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/article.rb b/app/models/article.rb index 5a3e3ad..b11703d 100644 --- a/app/models/article.rb +++ b/app/models/article.rb @@ -487,8 +487,8 @@ class Article < ActiveRecord::Base scope :more_recent, :order => "created_at DESC" scope :display_filter, lambda {|user, profile| - return published if (user.nil? && profile.public?) - return [] if user.nil? || (!profile.public? && !user.follows?(profile)) + return published if (user.nil? && profile && profile.public?) + return [] if user.nil? || profile.nil? || (!profile.public? && !user.follows?(profile)) where( [ "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ? -- libgit2 0.21.2