I want to extend registration form in one Rails app for users to be able to submit their roles.
It basically adds few check boxes in the form.
I’m using simple_form gem and it looks like this:
= f.input :role_mask, as: :check_boxes, label: false,
collection: ['Investor', 'Mentor', 'Developer', 'Other']
To keep this information in database, I added role_mask:integer field to the User model.
So if the user checked, say, Mentor and Developer, it should store 6 in role_mask field (its mask = 0110).
I know, this mapping could be done inside controller, but since I’m contributing to this app, I don’t want to touch controller. So I’m wondering does simple_form provide some tools to solve this or I should use JavaScript to do the mapping? Thanks for any help.
You are right. If you don’t want to do it in the controller you will have to do it client side. There is no way to simple_form generate the javascript, so you will have to do it yourself.