基于字符串选择的rails中的动态下拉列表

时间:2016-06-14 13:50:15

标签: ruby-on-rails ruby ruby-on-rails-4

我有一个下拉菜单:

<div class="form-group">
  <label for="usr">Degree Type:</label>
  <%= f.select(:degreetype, options_for_select([['Bachelor Degree'],['Masters Degree'],['PHD']]),{}, {class:"form-control"})%>
</div>

根据上面的选择,我想要不同的下拉列表

#if Bachelor Degree selected
<div class="form-group">
  <label for="usr">level:</label>
  <%= f.select(:level, options_for_select([['1st'],['2.1'],['2.2'],['3rd']]),{}, {class:"form-control"})%>
</div>

#if Master Degree selected
<div class="form-group">
  <label for="usr">level:</label>
  <%= f.select(:level, options_for_select([['1st'],['2.1'],['2.2'],['3rd']]),{}, {class:"form-control"})%>
</div>

:degreetype是字符串数据类型。

0 个答案:

没有答案