Last active
December 16, 2015 14:49
-
-
Save atleastimtrying/5451944 to your computer and use it in GitHub Desktop.
horrid index function
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
def index | |
@titles = Title.all | |
@genders = Gender.all | |
if not params[:find_by_student_id].blank? | |
@found_student = Student.find(params[:find_by_student_id]) | |
else | |
if(params.size > 4) | |
if params[:title_id].present? | |
@results = @results || Student | |
@results = @results.where('title_id = ? ', params[:title_id]) | |
end | |
if params[:first_name].present? | |
@results = @results || Student | |
@results = @results.where('first_name like ? ', params[:first_name]) | |
end | |
#@results = @results.where('last_name like ? ', sanitize(params[:last_name])) unless params[:last_name].blank? or params[:last_name].nil? | |
#@results = @results.where('gender_id = ? ', sanitize(params[:gender_id])) unless params[:gender_id].blank? or params[:gender_id].nil? | |
end | |
end | |
respond_to do |format| | |
format.html # index.html.erb | |
format.json { render json: @results } if @results | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
if params[:title_id].present?
@results = @results || Student
@results = @results.where('title_id = ? ', title_id)
end