Check checkbox by default Rails 4

necker

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!

Nikolay

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)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Check the checkbox by default

From Dev

How to check the checkbox by default?

From Dev

Check the checkbox by default

From Java

Rails 4 default scope

From Dev

Rails 4 default scope

From Dev

Rails simple form checkbox default to true

From Dev

Rails simple form checkbox default to true

From Dev

Ruby on Rails: Cannot check the checkbox in RSpec test

From Dev

Ruby on Rails: Cannot check the checkbox in RSpec test

From Dev

Angular4 - Check checkbox on cancel

From Dev

Rails 4, add checkbox for each object in a table?

From Dev

Single checkbox to update multiple attributes Rails 4

From Dev

Single checkbox to update multiple attributes Rails 4

From Dev

Rails check if field value is the default value for that field

From Dev

How to check a checkbox in a default column list in sharepoint 2013 with powershell?

From Dev

rails 4, change default form builder globally

From Dev

In Rails 4 disable Strong Parameters by default

From Dev

Rails 4 + Paperclip: Making a default profile picture

From Dev

Rails 4 default respond_to for ajax controller

From Dev

Rails 4 Make Default for f select null

From Dev

Converting Checkbox Status Check from Materialize to Bootstrap 4

From Dev

MVC 4 display/hide a textbox based on a checkbox check

From Dev

Multiple check box not working Rails 4

From Dev

Check for save after update Rails 4

From Dev

Check for existing association 'belongs_to' in Rails 4

From Dev

Check for save after update Rails 4

From Dev

Check if a checkbox is check in jQuery

From Dev

How to submit the form on checking the checkbox with its value in rails 4?

From Dev

Rails 4 Checkbox helper-table - Many_to_many

Related Related

HotTag

Archive