Skip to content

Instantly share code, notes, and snippets.

@basmoura
Created March 3, 2017 01:05
Show Gist options
  • Save basmoura/4a3ee2606a7f1f0b063b3ccac6b004d6 to your computer and use it in GitHub Desktop.
Save basmoura/4a3ee2606a7f1f0b063b3ccac6b004d6 to your computer and use it in GitHub Desktop.
def index
@cursos = Curso.all
if request.format =="application/json"
where = " ativo='S' and escritorio_id= "+params[:escritorio_id].to_s
else
where = " escritorio_id= "+current_user.escritorio_id.to_s
end
if params[:titulo] != nil && params[:titulo].length>0
where+=" and titulo like '%"+params[:titulo]+"%' "
end
if params[:ativo] != nil && params[:ativo].length>0
where+=" and ativo = '"+params[:ativo]+"' "
end
@cursos = @cursos.paginate(:page => params[:page], :per_page => 10).order('titulo ASC').where(where)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment