0

選擇標籤我有4個型號:OnChange事件在Rails的

class.rb

has_many :studies 
    has_many :students 

study.rb

belongs_to :class 
has_many :grades 

studen.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類標識碼,選擇更改值select_tag study_id和student_id數據(類的has_many:研究和的has_many:學生)?

回答

0

ok問題用javascript解決了