I can do this. Is there a more idiomatic way or something directly supported by the API?
transaction do
Organization.find_roles(:any, organization).where(resource_id: organization.id).pluck(:name).each |role_name|
remove_role(role_name, organization)
end
add_role('new_role', organization)
end
If you just want to get rid of all of those roles then this should do it: (basically what
remove_roledoes but without additional filters or callbacks)If you want it to act more like
remove_rolethen this might be a better way to go:Rolify::Adapter::RoleAdapter