Twitter bootstrap 使用引导选择视图在rails中进行下拉选择

Twitter bootstrap 使用引导选择视图在rails中进行下拉选择,twitter-bootstrap,ruby-on-rails-4,Twitter Bootstrap,Ruby On Rails 4,我在rails项目中有以下选择选项: <select name="reporter[website_ip]"> <%= options_from_collection_for_select(@websites,:website_ip, :website_address) %> </select> 并在下面选择引导html代码: <div class="control-group"> <label class

我在rails项目中有以下选择选项:

 <select name="reporter[website_ip]">
    <%= options_from_collection_for_select(@websites,:website_ip, :website_address) %>
 </select>

并在下面选择引导html代码:

   <div class="control-group">
      <label class="control-label">Medium Dropdown</label>
      <div class="controls">
        <select class="medium m-wrap" tabindex="1">
          <option value="Category 1">Category 1</option>
          <option value="Category 2">Category 2</option>
          ...
          <option value="Category n">Category n</option>
        </select>
      </div>
    </div>

中等下拉列表
第一类
第2类
...
类别n
我想在这个选择引导模板中使用rails选择选项。我该怎么做?我使用下面的代码,但不工作

<div class="control-group">
  <select name="reporter[website_ip]">
    <%= options_from_collection_for_select(@websites,:website_ip, :website_address) %>
  </select>
</div>

我相信你可以这样做:

<div class="control-group">
      <label class="control-label">Medium Dropdown</label>
      <div class="controls">
        <select name="reporter[website_ip]" class="medium m-wrap" tabindex="1">
           <%= options_from_collection_for_select(@websites,:website_ip, :website_address) %>
        </select>
      </div>
</div>

中等下拉列表

为什么要用“集合选择”替换“集合选择的选项”?然后我使用这段代码,我得到了“NoMethodError”,“undefined method'reporter[website\u ip]”。我已经用“options\u from\u collection\u for\u select”更新了答案,希望这段代码可以帮助你。