Skip to content

Instantly share code, notes, and snippets.

@thelinuxlich
Created October 25, 2011 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thelinuxlich/1312644 to your computer and use it in GitHub Desktop.
Save thelinuxlich/1312644 to your computer and use it in GitHub Desktop.
class CurriculoAluno < ActiveRecord::Base
set_table_name :curr_alunos
set_primary_keys :rgm,:num_ano_turma,:num_sem_turma,:cod_discip
belongs_to :disciplina,:foreign_key => :cod_discip
belongs_to :historico_de_matricula, :class_name => "HistoricoMatricula", :foreign_key => [:rgm,:num_ano_turma,:num_sem_turma]
has_many :horarios_de_aula,:class_name => "HorarioAula", :finder_sql => proc {
"SELECT * FROM HORARIOS_AULAS
WHERE NUM_ANO_TURMA = #{num_ano_turma_ad || num_ano_turma}
AND NUM_SEM_TURMA = #{num_sem_turma_ad || num_sem_turma} AND
COD_CENTRO = #{cod_centro_ad || cod_centro} AND COD_CURSO = #{cod_curso_ad || cod_curso} AND
COD_BLOCO = '#{cod_bloco_ad || cod_bloco}' AND IDT_PERIODO_BLOCO = '#{idt_periodo_bloco_ad || idt_periodo_bloco}' AND
NUM_PERIODO_TURMA = #{num_periodo_turma_ad || num_periodo_turma}
AND COD_TURMA = '#{cod_turma_ad || cod_turma}' AND
COD_DISCIP = #{cod_discip_ad || cod_discip}"
}
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment