0

私は4つのモデルを持っています:

class.rb

  has_many :studies
  has_many :students

study.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_tag値を変更する方法と、、、study_id(クラスと)student_idを選択したときは?select_tagclass_idhas_many :studieshas_many :students

4

1 に答える 1

0

OK問題はjavascriptで解決

于 2013-01-27T15:47:02.850 に答える