0

我有 4 个模型:

类.rb

  has_many :studies
  has_many :students

研究.rb

belongs_to :class
has_many :grades

学生.rb

belongs_to :class, :counter_cache => :student_count
has_many :grades

等级.rb

belongs_to :student
belongs_to :course

关于成绩/_form.html.erb

<div class="field">
        <%= f.label :class_id %><br />
         <%= f.select :class_id, Class.all.collect {|x| [x.name, x.id]}, {:include_blank => "chose class"}, :multiple => false %>
      </div>

      <div class="field">
        <%= f.label :study_id %><br />
         <%= f.select :study_id, Study.all.collect {|x| [x.name+" "+x.class.name, x.id]}, {:include_blank => "chose study"}, :multiple => false %>
      </div>
      <div class="field">
        <%= f.label :student_id %><br />
        <%= f.select :student_id, Student.where(:study_id => :study_id).collect {|x| [x.name, x.id]}, {:include_blank => "Chose Student"}, :multiple => false %>
      </div>

如何更改值select_tagstudy_id以及student_id当我选择select_tag, class_id, (class has_many :studiesand has_many :students) 时?

4

1 回答 1

0

好的问题用javascript解决了

于 2013-01-27T15:47:02.850 回答