When submit a form , rails will strip empty params
so you cannot update roles by just clear all roles from this variable.
this is an expected behavior in rails (for security reason)
I also have to try to disable deep_munge but still no luck
# config/application.rb config.action_dispatch.deep_munge = false
Finally, I try solution below, and it works
= hidden_field_tag('variable[role_ids][]', nil)