Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Multiple checkboxes for ruby array
#MODEL
serialize :storage_type
#CONTROLLER
:storage_type => []
#FORM
#STORE = model
<div class="field">
<%= check_box("store", :storage_type, {:multiple => true}, "Self Storage", nil) %> Self Storage
<%= check_box("store", :storage_type, {:multiple => true}, "fetch", nil) %> fetch
<%= check_box("store", :storage_type, {:multiple => true}, "roll_over", nil) %> roll_over
</div>
#OUTPUTTED
<div class="field">
<input checked="checked" id="store_storage_type_self_storage" name="store[storage_type][]" type="checkbox" value="Self Storage"> Self Storage
<input checked="checked" id="store_storage_type_fetch" name="store[storage_type][]" type="checkbox" value="fetch"> fetch
<input checked="checked" id="store_storage_type_roll_over" name="store[storage_type][]" type="checkbox" value="roll_over"> roll_over
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.