Skip to content

Instantly share code, notes, and snippets.

@marialecodes
Created March 30, 2015 21:05
Show Gist options
  • Save marialecodes/47d10495aef205a4f23e to your computer and use it in GitHub Desktop.
Save marialecodes/47d10495aef205a4f23e to your computer and use it in GitHub Desktop.
# /controllers/tutor_controller.rb
def index
@conceptos = Concepto.all
@conocimientos_usuario = current_user.conocimientos
@nivel = 0
@i = 1
@conceptos_por_nivel = Concepto.group(:nivel).count
@conocidos_por_nivel = Concepto.joins(:conocimientos).where(conocimientos: { conocido: true }).where(conocimientos: { user_id: current_user.id }).group(:nivel).count
end
# /views/tutor/index.html.erb
<% @conceptos.each do |concepto| %>
<% if concepto.nivel != @nivel %>
<%= mostrar_progreso_nivel(concepto.nivel, calcular_progreso[@i]) %>
<% @nivel = concepto.nivel %>
<% @i += 1 %>
<% end %>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment