i followed the example on docs, could you explain?...
# support
w
i followed the example on docs, could you explain? Thanks anyway.
n
which example did you follow? the one here shows it as
module
https://guides.solidus.io/developers/customizations/state-machines#state-machines
w
These are the new docs about state machines: https://edgeguides.solidus.io/advanced-solidus/state-machines
However, there's no hard requirement in using a Module or a Class. That's your code, so you can't organize it as you like.
The error you're getting is because you are probably defining a
MyStore::StateMachines
module somewhere else.
apparently, in a Zeitwerk callback
you can reproduce this error in irb:
Copy code
irb(main):001:1* module A
irb(main):002:2*   module B
irb(main):003:1*   end
irb(main):004:0> end
=> nil
irb(main):005:1* module A
irb(main):006:2*   class B
irb(main):007:1*   end
irb(main):008:0> end
Traceback (most recent call last):
# ...
TypeError (B is not a class)
(irb):2: previous definition of B was here
w
the example is on *edgeguides.solidus.io*… i did not defined
MyStore::StateMachines
anywhere else, and on solidus
core/state_machines/order.rb
state machine is defined as
Copy code
module Spree
  module Core
    class StateMachines
      module Order
w
Could you share all the contents of the file?
w
as a test i just took all the code of solidus
lib/spree/core/state_machines/order.rb
Copy code
module Spree
  module Core
    class StateMachines
      module Order
...
and copied under my name space on
lib/my_store/state_machines/order.rb
Copy code
module MyStore
  class StateMachines
    module Order
....
i suppose this is due to the way the class StateMachines compose its own pieces…
w
Even if StateMachines is a Class on Solidus, you should definitely use a module as namespace. Does that fix your issue?