我的表单中有一个收藏复选框,如下所示。
<% ["cricket" ,"tennis", "not there in list"].each do |c| %>
<div class="col-md-4" >
<p><%= f.check_box :game, {:multiple => true, checked: @training.game&.include?(c), class: "reason-for-the-test"}, c, "" %> <%= c.capitalize.tr("_"," ") %></p>
</div>
<% end %>
目前,复选框的标签及其在数据库中保存的值都是相同的。我想为标签的数据库保存不同的值。我尝试如下。但它不起作用。任何人都可以帮助我。
<% [["cricket","cri"] ,["tennis","ten"], ["not there in list","na"]].each do |c| %>
<div class="col-md-4" >
<p><%= f.check_box :game, {:multiple => true, checked: @training.game&.include?(c), class: "reason-for-the-test"}, c, "" %> <%= c.capitalize.tr("_"," ") %></p>
</div>
<% end %>
答案 0 :(得分:0)
<div class="wrapper">
<div class="wrapper__item">
<div class="wrapper__content">
<h3 class="wrapper__title">Default title</h3>
<div class="wrapper__text">Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla porttitor accumsan tincidunt. Donec rutrum congue leo eget malesuada. Sed porttitor lectus nibh.</div>
<p class="wrapper__date">08.02.2018</p>
</div>
</div>
<div class="wrapper__item">
<div class="wrapper__image-container"><img class="wrapper__image" src="http://accessasiatours.com/wp-content/uploads/2017/11/panda.jpg"
alt="Testimage"></div>
<div class="wrapper__content">
<h3 class="wrapper__title">Default title</h3>
<div class="wrapper__text">Curabitur non nulla sit amet nisl tempus convallis quis ac lectus. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Nulla porttitor accumsan tincidunt. Donec rutrum congue leo eget malesuada. Sed porttitor lectus nibh.</div>
<p class="wrapper__date">08.02.2018</p>
</div>
</div>
</div>