Skip to content

Instantly share code, notes, and snippets.

@spacecowb0y
Created April 4, 2012 20:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save spacecowb0y/2305527 to your computer and use it in GitHub Desktop.
Save spacecowb0y/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