Onchange事件以在Rails中选择标签

问题描述 投票:0回答:1

我有4个型号:

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

grade.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_tagclass_id has_many类上选择)时如何更改值:studieshas_many:students

ruby-on-rails associations html-select onchange
1个回答
0
投票
可以用javascript解决的问题
© www.soinside.com 2019 - 2024. All rights reserved.