How to make a check_box checked in rails?

checkbox, form-helpers, ruby-on-rails, ruby-on-rails-3, ruby-on-rails-3.2

Solution

Here's how to do it as of rails 4, I didn't check older documentation.

<%= check_box("tag", tag.id, {checked: true}) %>

This will make the checkbox checked. Of course instead of `true` you will put in some logic which determines if each one is checked.

Problem

I made checkboxes using the following rails form helper: ``` <%= check_box("tag", tag.id) %> ``` However, I need to make some of them checked by default. The rails documentation doesn't specify how to do this. Is there a way? How?

Original source

Related problems