enum value is wrong if define two inherited class with aasm and on rails.env.production
Describe the bug
i define two inherited class with aasm,for example :
class Aasm01 < ApplicatioinRecord
aasm column: 'state01', enum: :state01_enum_hash do
....
end
end
class Aasm02 < aasm01
aasm column: 'state02', enum: :state02_enum_hash do
....
end
end
everything is ok when do rails.env.developement model
but, something wrong when do rails.env.production model
AASM::StateMachineStore.fetch(Aasm01, true).machine('default').config.enum # => :state02_enum_hash
AASM::StateMachineStore.fetch(Aasm02, true).machine('default').config.enum # => :state02_enum_hash
as above, Aasm01 use a wrong enum value which seem to fetch from Aasm02 , :(
@openxyz Are you sure this environment related? Probably just a load order difference in development and production, so on dev another configurations wins vs prod.
aasm column: 'state02'does to my knowledge use the default state machine. So basically you might only have one state machine, with one configuration.
Read up on using multiple state machines in one class, which is what you need when you inherit.
Try using a named machine instead:
aasm :state01, column: 'state01', enum: :state01_enum_hash do …