necker
necker

Reputation: 7163

Check checkbox by default Rails 4

I have a form_for Horse.new

Then I have a line

 <%= f.check_box :is_public, {checked: true, class: "positionRelative marginTopM3"} %>

Which creates the following HTML

 <input checked="checked" class="positionRelative marginTopM3" id="horse_is_public" name="horse[is_public]" type="checkbox" value="1">

Though the checkbox is not checked. What am I doing wrong?

I also tried Horse.new(is_public: true) but to no avail.

I am really lost here been googling around for an hour now without success. Will appreciate any answers!

Upvotes: 0

Views: 172

Answers (1)

Nikolay
Nikolay

Reputation: 1392

It might be the browser, your HTML says checked="checked" which is what rails will generate if your is_public set to true and that's what it should be. try to clean up your browser cache (try different browser as well)

Upvotes: 1

Related Questions