Kim
Kim

Reputation: 2156

Ruby on Rails -- assign a value to a checkbox

I want to assign a value to a checkbox. The code below doesn't seem to work

Same Section <%= f.check_box :LSU_TYPE,  :value =>"Same Section" %>

Instead of storing 'Same Section' in the table, value '1' is stored when i check the box.

What am i doing wrong here?

Upvotes: 0

Views: 1289

Answers (2)

suely
suely

Reputation: 434

@Kum this works for me:

<div><%= f.label :pay_with_card? %></br>
<%= f.check_box :pay_with_card,{}, "Yes", "No"%>  

good luck!

Upvotes: 1

cjm2671
cjm2671

Reputation: 19466

A checkbox is a boolean field. It can only accept 1 or 0, 'True' or 'False'.

Upvotes: 4

Related Questions