This is the first post of a beginner. I will post it in a memo so that I will not forget it.
form_with helper method I'm trying to create a checkbox using collection_check_boxes.
・ What you want to implement Only the name of the customer registered by the logged-in user I want to display it as a check box (current_user.id == user.id I want to make the name of the customer table of the check box. )
Normal description method Here, the names of all customer tables become checkboxes.
= f.collection_check_boxes :customer_ids, Customer.all, :id, :name
solution ↓ I was able to solve it here.
= f.collection_check_boxes :customer_ids, Customer.where(user_id: current_user.id), :id, :name
It's a simple content, I couldn't find an article with the same content pinpointed, so I posted it.
I would appreciate it if you could comment if there are any mistakes in the description.
Recommended Posts