Skip to content

Instantly share code, notes, and snippets.

@atleastimtrying
Last active December 16, 2015 14:49
Show Gist options
  • Save atleastimtrying/5451944 to your computer and use it in GitHub Desktop.
Save atleastimtrying/5451944 to your computer and use it in GitHub Desktop.
horrid index function
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
@MrJaba
Copy link

MrJaba commented Apr 24, 2013

if params[:title_id].present?
@results = @results || Student
@results = @results.where('title_id = ? ', title_id)
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment