Reputation: 2443
I have like to set all the check boxes here to be checked by default. I tried a few methods from so but somehow could not get it to work.
<div class="mr-6 text-xs">
<%= f.collection_check_boxes(:clazz, @staff.clazzes.map { |c|
[ ' ' + c.name + ' ', c.id]
}, :last, :first) %>
</div>
Any help or suggestion would be greatly appreciated.
The whole form looks like this: https://gist.github.com/somaria/7d2bd484b8a45fa0623337ec397dfd3e
Upvotes: 0
Views: 457
Reputation: 15298
Something like this
<div class="mr-6 text-xs">
<%= f.collection_check_boxes(:clazz, @staff.clazzes.map { |c| [ " #{c.name} ", c.id] }, :last, :first) do |b| %>
<%= b.label { b.check_box(checked: true) + b.text } %>
<% end %>
</div>
Upvotes: 1