Preselect Check box with Rails Simple_form

If you don't want to, or cannot update your migration to do 'PerfectlyNormal's answer, then you can add the following to the end of your f.input:

:input_html => { :checked => true }

So, it would become:

= f.input :some_flag, :input_html => { :checked => true }

Hope that helps!


the best way would be to set the default value in your model, something like

create_table :my_table do |t|
  ...
  t.boolean :my_boolean, :default => true
  ...
end

which simple_form will pick up on, and set the checkbox to be checked by default.

A simpler way is to do it as Dave says, and just force the value to 1, but if a validation fails, and you display the form again, it will still be checked, regardless of how it looked when the form was submitted.