I have a Rails 5 app.
template _form
- if current_user&.super_admin
.form-group.has-feedback
.text-muted
= f.label 'Which users should see this?'
= f.collection_select(:user_templates, User.all, :id, :name, { include_hidden: false }, multiple: 'true', class: 'select')
It's a multiple select form. When submitting the form I send an array of users to my controller and save it in my user_template
table, which creates a new row for every users that was selected. Works perfectly.
However, when I edit the specific template I would like to show the users that was saved the first time. I can easily query them in the db and get all the right users but I cannot show them as selected
in the multiple dropdown.
Any ideas?