【发布时间】:2014-07-04 19:12:21
【问题描述】:
我使用脚手架生成了一个模型。
rails g scaffold attendance ename:string entertime:datetime sl:boolean mrgsl:boolean evesl:boolean halfday:boolean
现在我想使用 simple_form 来展示它,并且我想在它们之间建立这些关系:
sl--> 有两种类型 i) mrgsl。 ii) evesl。
因此,选择SL(CHECK_BOX),然后选择两个RORORY_BUTTONS,选择两个中的任何一个。 而且 halfday 也是一个复选框。
<%= simple_form_for @attendance, :html => { :class => 'form-horizontal' } do |f| %>
<%= f.input :ename %>
<%= f.input :entertime, as: :time %>
<%= f.input :sl, as: :check_box %>
<%= f.input :mrgsl, as: :radio_button %>
<%= f.input :evesl, as: :radio_button %>
<%= f.input :halfday, as: :check_box %>
<div class="form-group">
<div class='col-md-offset-2 col-md-10'>
<%= f.submit nil, :class => 'btn btn-primary' %>
<%= link_to t('.cancel', :default => t("helpers.links.cancel")),
attendances_path, :class => 'btn btn-default' %>
</div>
</div>
<% end %>
这就是我尝试这样做但它不起作用的方式。
RuntimeError in Attendances#new
Showing /home/pallavsharma/Workspace/crm/app/views/attendances/_form.html.erb where line #4 raised:
No input found for check_box
1<%= simple_form_for @attendance, :html => { :class => 'form-horizontal' } do |f| %>
2<%= f.input :ename %>
3<%= f.input :entertime, as: :time %>
4<%= f.input :sl, as: :check_box %>
5<%= f.input :mrgsl, as: :radio_button %>
6<%= f.input :evesl, as: :radio_button %>
7<%= f.input :halfday, as: :check_box %>
有哪些可能的方法。
【问题讨论】:
标签: ruby-on-rails ruby-on-rails-4 simple-form