Skip to content

How to create two enums with same key value within a single class? #46

@shashikant-lokare

Description

@shashikant-lokare

Example, if I try to create like below, it will give error
ArgumentError (You tried to define an enum named "payment_sub_status" on the model "OrderPayments::Payment", but this will generate a instance method "pending?", which is already defined by another enum.)

enum payment_status: { pending: 1, success: 2, failed: 3, cancelled: 4 } do
event :succeed do
after do
self.update_sub_status 'success'
end
transition %i[success pending failed] => :success
end
end

enum payment_status2: { pending: 1, success: 2, failed: 3, cancelled: 4 } do
event :succeed do
after do
self.update_sub_status 'success'
end
transition %i[success pending failed] => :success
end
end

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions