3

I am implement a order system with AASM, but when I use rails c to check the function, but something wrong happen. NameError: uninitialized constant Order::AASM

Bug showed in console

There is gem 'aasm' in the Gemfile. I have searched Google and StackOverflow with NameError: uninitialized constant Order::AASM, but got nothing that did work.

I have reload bundle install and rails s, even reboot the computer. This is my code.

enter image description here

order's gist is here.

How to fix this? And if I can't find the right question, or you need more information, could you point it?

zedong
  • 393
  • 2
  • 5
  • 15

2 Answers2

2

Try this:

  1. Comment out gem 'spring'and gem 'spring-watcher-listen', '~> 2.0.0'

  2. Run bundle install

Or try upgrading spring in your project:

  1. In your gemfile gem 'spring', '~> 2.0', '>= 2.0.2'
  2. Run bundle update spring
Drenmi
  • 8,492
  • 4
  • 42
  • 51
  • Def seems like it's an issue with `spring`. I don't have `spring-watcher-listen` in my project but still have the issue. Commenting it out fixes it. – dft Jul 12 '17 at 03:16
0

You might want to include more code into your question - the whole aasm block.

Also, try specifying the model db column you are applying your AASM states to:

  aasm :column => 'state'
    state :active
    state :completed
    state :scheduled
The Whiz of Oz
  • 6,763
  • 9
  • 48
  • 85