Last active
August 29, 2015 13:55
-
-
Save EminenceHC/8714890 to your computer and use it in GitHub Desktop.
Conditional .where on Social Security No
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
runquery = Student.joins(:user) | |
runquery = runquery.where(users: {first_name: params[:first_name]}) if params[:first_name].present? | |
runquery = runquery.where(users: {last_name: params[:last_name]}) if params[:last_name].present? | |
runquery = runquery.where(users: {loginable_id: params[:id]}) if params[:id].present? | |
runquery = runquery.where(program: params[:program]) if params[:program].present? | |
runquery = runquery.where(users: {social_security_no: '000000000'}) if params[:social_security_no] == 'no_social' # '000000000' || '' || '0' | |
runquery = runquery.select('students.*, students.id as sid, users.*') | |
@query = runquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment