Topic: Inherit parent foreign key ids

Hello.

I have following models.

class SchoolClass < ActiveRecord::Base
  has_many :students
end

class Student < User
  belongs_to :school_class
  belongs_to :teacher
end

class Teacher < User
  has_many :students
end

Is there trick to automaticly set teacher_id when I do in controller:

@student = @teacher.school_classes.first.students.build(params[:student])
@student.teacher_id == @teacher.school_classes.first.teacher_id # => true

??

I know i can do before_validation callback to set it, but maybe there is another build in solution.