From 2547177caf4809628d9f26704a071224027173cb Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Thu, 12 Jun 2014 11:14:47 -0300 Subject: [PATCH] rails3: fix profile_list_block query --- app/models/profile_list_block.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/profile_list_block.rb b/app/models/profile_list_block.rb index b6d1a0d..13e1afb 100644 --- a/app/models/profile_list_block.rb +++ b/app/models/profile_list_block.rb @@ -18,9 +18,9 @@ class ProfileListBlock < Block result = nil visible_profiles = profiles.visible.includes([:image,:domains,:preferred_domain,:environment]) if !prioritize_profiles_with_image - result = visible_profiles.all(:limit => limit, :order => 'updated_at DESC').sort_by{ rand } + result = visible_profiles.all(:limit => limit, :order => 'profiles.updated_at DESC').sort_by{ rand } elsif profiles.visible.with_image.count >= limit - result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'updated_at DESC').sort_by{ rand } + result = visible_profiles.with_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } else result = visible_profiles.with_image.sort_by{ rand } + visible_profiles.without_image.all(:limit => limit * 5, :order => 'profiles.updated_at DESC').sort_by{ rand } end -- libgit2 0.21.2