Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support enumerization of the same attribute in child class. #448

Merged
merged 1 commit into from
Mar 19, 2024

Conversation

nashby
Copy link
Member

@nashby nashby commented Mar 19, 2024

Typical use case of this is:

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.

@nashby nashby merged commit 47f0dc5 into master Mar 19, 2024
98 checks passed
@nashby nashby deleted the inheritance-fix branch March 19, 2024 20:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant