Skip to content

Instantly share code, notes, and snippets.

@ykyk1218
Last active March 23, 2017 07:41
Show Gist options
  • Save ykyk1218/3b80ac636f051596f6eec816b56ee82e to your computer and use it in GitHub Desktop.
Save ykyk1218/3b80ac636f051596f6eec816b56ee82e to your computer and use it in GitHub Desktop.
railsのscopeでA→B→Cの関連テーブルでCの条件で絞り込みたい時
scope :condition, -> {
joins(B: :C).where(C: {C_column: "hoge"})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment