Reputation: 7314
I have an Available
model with a date attribute, I also have a User
model. A user has_many :availables
and available belongs_to :user
.
@dates is a collection of Available records. In the form I want to show both the date and the associated user name for that record. What I currently have is working though I can't click name to select the checkbox, is there a proper way to do this and style it via bootstrap?
= f.collection_check_boxes :col_ids, @dates, :id, :date do |b|
.field
.checkbox-inline
= b.check_box
= b.label
= b.object.user.name
Upvotes: 0
Views: 344
Reputation: 101811
What you want is a checkbox which is inside the label tag.
= f.collection_check_boxes :col_ids, @dates, :id, :date do |b|
.field
.checkbox-inline
= b.label do
= b.check_box
= b.text
= b.object.user.name
On a side note your model should be named Availablity
which is a noun. Not the adverb form available (availables is not an english word).
A person may be available, but has many availabilities.
availability
plural avail·abil·i·ties
- the quality or state of being available
- an available person or thing
This is not a big deal but can give english speakers are real WTF moment when trying to understand your code.
Upvotes: 1