noo*_*oob 3 ruby-on-rails simple-form
我有一个简单的代码表格:
<%= simple_form_for @business, :html => {:class => "form-inline"} do |f| %>
<%= f.association :business_type, :as => :collection_select, :input_html => {:class => "input-small"}, :label => "Type of Business"%>
<%= f.button :submit, :class => "primary pull-left" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
在business type模型中,我有以下内容:first_tier,second_tier,third_tier.
我希望select允许用户选择business type模型中的所有选项,除了first_tier选项外,但无法使其工作.
谢谢.
您可以使用以下方法限制收集选项:
f.association :business_type, :as => :collection_select, collection: BusinessType.where('biztype <>?', 1), :input_html => {:class => "input-small"}, :label => "Type of Business"
Run Code Online (Sandbox Code Playgroud)
我不确定您使用什么变量来定义层,但是当它不等于first_tier来限制业务类型选项时,该变量只是寻找.可以在文档中找到更多信息.
| 归档时间: |
|
| 查看次数: |
4430 次 |
| 最近记录: |