How can I make a check box default to being \"checked\" when it is initially displayed?
I\'ve not found a \"Rails\" way to do this (that works) so I did it with JavaScr
I was shocked that none of the answers solve 100% of the problem. As all suggested solutions will give checked result on edit form, even if the user unchecked the checkbox.
checked
<%= f.check_box :subscribe, checked: @event.new_record? || f.object.subscribe? %>
Works for rails 4 +, not tested below.