Skip to content

Instantly share code, notes, and snippets.

@barce
Created June 27, 2014 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save barce/4c7775c1fde0436eb24f to your computer and use it in GitHub Desktop.
Save barce/4c7775c1fde0436eb24f to your computer and use it in GitHub Desktop.
# Role to delete: viewer
# get role
role = Role.find_by_name('viewer')
# get user
user = User.find_by_email('foo@example.com')
# delete role by looping through role assignments
user.role_assignments.each do |ra|
ra.destroy! if ra.role_id == role.id
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment