My User model looks similar to this:
class User < ActiveRecord::Base
enum type: [:admin, :reviewer, :super_admin ]
validates :type, presence: true
validates :type, inclusion: { in: User.types.keys }
end
When I submit anything outside the enum values, the validation doesn't stop the code from running, and I get a 500 error as a response with the following error:
'something submitted' is not a valid type
If I submit a blank field, the validation works:
"type": [
"can't be blank",
"is not included in the list"
]
What am I doing wrong? My code looks identical to this answer