aasm / aasm/aasm

enum value is wrong if define two inherited class with aasm and on rails.env.production

Open
#744 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Ruby
Stars
5.2k
Forks
644
PR merge metrics
No merged PRs in 30d

Description

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 , :(

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No repository file or test is named. Start by reproducing the production-only behavior with the Aasm01/Aasm02 inheritance example, then inspect AASM::StateMachineStore.fetch and each machine's config.enum. Done means Aasm01 retains state01_enum_hash while Aasm02 retains state02_enum_hash.

Written by the indexing model from the issue text.

Assessment

Tech stack
rails, ruby
Domain
backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.