Skip to content

Instantly share code, notes, and snippets.

@banguyenht
Last active January 5, 2022 11:02
Show Gist options
  • Save banguyenht/2e531a8e0082b18608e2c117312b38c0 to your computer and use it in GitHub Desktop.
Save banguyenht/2e531a8e0082b18608e2c117312b38c0 to your computer and use it in GitHub Desktop.
rails joins 3 tables
scope :abc, ->(company_id) {
A.joins(b: :c).merge(A.where(company_id: company_id)) if company_id.present?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment