Skip to content

Instantly share code, notes, and snippets.

@peterclark
Last active December 21, 2018 18:01
Show Gist options
  • Save peterclark/9ba125390b831c206e68ace8f1be1fbb to your computer and use it in GitHub Desktop.
Save peterclark/9ba125390b831c206e68ace8f1be1fbb to your computer and use it in GitHub Desktop.
rails collection checkboxes
# for has_and_belongs_to_many, required true
= f.collection_check_boxes :ethnicity_ids, Ethnicity.all, :id, :name, {}, { required: true } do |e|
= e.label do
= e.check_box
= e.text
# or for has_many through with different wrappers
= f.collection_check_boxes :health_goal_ids, HealthGoal.ordered, :id, :name, boolean_style: :inline, item_wrapper_tag: nil do |goal|
.c-radio.c-radio--square.c-radio--rectangle.c-radio--orange.c-radio--50
= goal.check_box
= goal.label do
%span= goal.text
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment