I am trying to re render a page with a checkbox that has been selected prior to the render.
With the result, I converted it to an integer.
if I have the following code, how do I make the checkbox either checked or not
check_box("price", "total", {:checked => @checkVal}) where @checkVal is my checked/not value (int)
If you are using check_box, Rails is assuming that you have a
@priceobject that has atotalattribute. If this is the case, you can set the checkbox to be checked by setting@price.totalto true (likely in your controller). Example:will result in a checked box in your view:
If you don’t have a Price model with a total attribute, you likely should be using check_box_tag instead (which has info on how to set checked).