class User < ActiveRecord::Base
enumerize :role, in: [:user]
end
class Admin < User
enumerize :role, in: [:user, :admin]
end
So if we want to redefine enumerized field in a child class we call enumerize again and that's causes issue since we try to decorate this role field again and when we try to cast given value we end up with calling cast on enumerized Type object but for already decorated attribute we just want to return its plain value, not a casted one.
Typical use case of this is:
So if we want to redefine enumerized field in a child class we call
enumerize
again and that's causes issue since we try to decorate thisrole
field again and when we try tocast
given value we end up with callingcast
on enumerizedType
object but for already decorated attribute we just want to return its plain value, not a casted one.