Enums in rails 8 can no longer be defined by a hash. That is, you can't
pass a hash to enum but you can still use a hash to define the values:
class User < ApplicationRecord
# removed in rails 8
enum roles: { volunteer: 0, admin: 1 }
# allowed in rails 8
enum :roles, { volunteer: 0, admin: 1 }
end
We're not on rails 8, but we'd like to upgrade to 7.2. v7.2 prints a
deprecation warning, so this takes care of that warning.
This fixes our enums to use the new format. I also took the opportunity
to clean up some of the enum logic in the User model. We were (maybe
unintentionally) overriding the generated enum methods like
volunteer?. This allowed us to pass an optional organization argument
to check if a user was a part of an org. I replaced these with better
named methods that require an org.