rails check_box_tag set checked with default value

后端 未结 6 1396
说谎
说谎 2021-02-18 14:38

I currently have a rails check_box_tag call that looks like

check_box_tag #{name}

I want to include a checked attribute, which I know I can do

6条回答
  •  长情又很酷
    2021-02-18 14:50

    If anyone have column type boolean then look at this. is_checked? will be default boolean value. It worked for me.

    <%= hidden_field_tag :name, 'false' %> <%= check_box_tag :name, true, is_checked? %>

提交回复
热议问题