Commit 5d5380a79a2e21e05619d03f4bbb6cca4ac957f3

Authored by Leandro Santos
1 parent d7093949

return empty array when nil profile is passed as parameter

Showing 1 changed file with 2 additions and 2 deletions   Show diff stats
app/models/article.rb
@@ -487,8 +487,8 @@ class Article < ActiveRecord::Base @@ -487,8 +487,8 @@ class Article < ActiveRecord::Base
487 scope :more_recent, :order => "created_at DESC" 487 scope :more_recent, :order => "created_at DESC"
488 488
489 scope :display_filter, lambda {|user, profile| 489 scope :display_filter, lambda {|user, profile|
490 - return published if (user.nil? && profile.public?)  
491 - return [] if user.nil? || (!profile.public? && !user.follows?(profile)) 490 + return published if (user.nil? && profile && profile.public?)
  491 + return [] if user.nil? || profile.nil? || (!profile.public? && !user.follows?(profile))
492 where( 492 where(
493 [ 493 [
494 "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ? 494 "published = ? OR last_changed_by_id = ? OR profile_id = ? OR ?