base_controller's get_additional_homepage_data function:

  def get_additional_homepage_data
    @sidebar_right = true
    @homepage_features = HomepageFeature.find_features
    @homepage_features_data = @homepage_features.collect {|f| [f.id, 
f.public_filename(:large) ]  }    
    
    @active_users = User.active.find_by_activity({:limit => 5, :require_avatar 
=> false})
    @featured_writers = User.find_featured

    @featured_posts = Post.find_featured
    
    @topics = Topic.find(:all, :limit => 5, :order => "replied_at DESC")

    @active_contest = Contest.get_active
    @popular_posts = Post.find_popular({:limit => 10})    
    @popular_polls = Poll.find_popular(:limit => 8)
  end

I fixed this by modifying User.find_by_activity:

  def self.find_by_activity(options = {})
    options.reverse_merge! :limit => 30, :require_avatar => true, :since => 
7.days.ago   
    activities = Activity.since(options[:since]).find(:all, 
      :select => 'activities.user_id, count(*) as count', 
      :group => 'activities.user_id', 
-     :conditions => "#{options[:require_avatar] ? ' users.avatar_id IS NOT 
NULL' : nil}", 
+     :conditions => "users.activated_at IS NOT NULL #{options[:require_avatar] 
? 'AND users.avatar_id IS NOT NULL' : ''}", 
      :order => 'count DESC', 
      :joins => "LEFT JOIN users ON users.id = activities.user_id",
      :limit => options[:limit]
      )
    activities.map{|a| find(a.user_id) }
  end  

and then just making the call User.find_by_activity.  I couldn't really 
envision a case where you'd want find_by_activity to include inactive members 
anyway.

Patrick


On May 13, 2010, at 12:12 PM, Bruno Bornsztein wrote:

> Jim, you're correct. Patrick, where is "User.active.find_by_activity" being 
> called from?
> 
> On Wed, May 12, 2010 at 10:31 PM, Jim Ruther Nill <[email protected]> wrote:
> Hi! Correct me if I'm wrong but named_scopes won't work on this because it's 
> not an active_record method.  
> So User.active.find_by_activity won't really scope for active users only.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "CommunityEngine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/communityengine?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "CommunityEngine" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/communityengine?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"CommunityEngine" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/communityengine?hl=en.

Reply via email to