Skip to content

Instantly share code, notes, and snippets.

@spacegauch0
Created April 4, 2012 20:52
Show Gist options
  • Select an option

  • Save spacegauch0/2305527 to your computer and use it in GitHub Desktop.

Select an option

Save spacegauch0/2305527 to your computer and use it in GitHub Desktop.
User active scope
class User < ActiveRecord::Base
has_many :projects
scope :active, User.joins(:projects).where('projects.id in (?)', Project.active.collect(&:id)).group('user_id')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment