pluginaweek / state_machine

Adds support for creating state machines for attributes on any Ruby class
http://www.pluginaweek.org
MIT License
3.74k stars 510 forks source link

Error: Different defined default values #358

Open MichaelA59 opened 6 years ago

MichaelA59 commented 6 years ago

I get the following error in my console.

Both Coach and its :current_joyride_bot_message machine have defined a different default for "current_joyride_bot_message". Use only one or the other for defining defaults to avoid unexpected behaviors.

It's showing up all the time and I don't know why. As you can see below, the default value for this attribute is identical to where the state machine begins, so I don't understand the meaning of this error. I would like to find a way to get rid of it, or if something is truly incorrect here, fix it.

From the Schema for coaches table

t.integer  "current_joyride_bot_message",       default: 1

From Coach model where the state machine resides

state_machine :current_joyride_bot_message, initial: 1 do
    event :next_joyride_step do
      transition 1 => 2, 2 => 3, 3 => 4, 4 => 5, 5 => 6, 6 => 7, 7 => 8, 8 => 9, 9 => 10, 10 => 11, 11 => 12, 12 => 13
    end
  end
bidva commented 6 years ago

I had the same issue as you and I made the column to be nullable and that fixed the issue