how can i assign a value to a check box in erb?

helper, ruby, ruby-on-rails, ruby-on-rails-3, view

Solution

This is the definition of this helper method:

check_box (object_name, method, options = {}, checked_value = "1", unchecked_value = "0")

So I supose you need something like:

<%= check_box :type, {}, "AB", "nil" %> AB <br><br>

But in your rails application you get string `'AB'` and string `'nil'`, that how it works.

Problem

``` <%= f.check_box:TYPE %> AB <br><br> ``` I have used the above mentioned in my code and when i click submit it takes `1` if `checked` and `0` if `not checked`and it is stored in `db`. How can i store a `string` like `AB` if `checked` and `nil` if `not checked` and i want to store that string in `db` instead of `0 and 1`?

Original source