Created
June 3, 2017 01:29
-
-
Save mkhuda/36d521285ba45c7f66e692ecc553c9bf to your computer and use it in GitHub Desktop.
Using INCLUDES and WHERE NOT IN on ActiveRecord
This file contains hidden or 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
# select user where id not in and where translator category is | |
def search | |
User.includes(:levels, :translator_categories).where('levels.name = ? AND translator_categories.name = ?', 'translator', 'Umum').where('users.id NOT IN (?)', [1,5,3,2]).references(:levels, :translator_categories) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment