Last active
June 7, 2017 16:18
-
-
Save TakuyaHarayama/09ed4e5a7ac92db0de4d05b32b250a5e to your computer and use it in GitHub Desktop.
ユーザーと映画とユーザーのお気に入り映画があって、特定のユーザーのお気に入りの映画と邦画を合わせて取得するscope
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scope :search_with_japanese_favorite_movie, -> (user_id) { | |
eager_load(:user_favorite_movies) | |
.merge( UserFavoriteMovie.where(user_id: user_id) ) | |
.or( Movie.eager_load(:user_favorite_movies).where(made_in: "Japan") ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment