Skip to content

Instantly share code, notes, and snippets.

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 rafaelcgo/e1bfdc54d96c34ee0e20 to your computer and use it in GitHub Desktop.
Save rafaelcgo/e1bfdc54d96c34ee0e20 to your computer and use it in GitHub Desktop.
queries-users_from_activities_of_organization.rb
Organization.first.activities.map(&:users)
User.where(id: Organization.first.activity_users.pluck(:user_id))
User.includes(activity_users: {activities: :organizations}).where(organization_id: Organization.first)
User.includes(activity_users: {activity: :organization}).where(activities: {organization_id: Organization.first})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment