title: State Machine Gem + Rails 4: undefined method `state_machine' for #<Class:0x007faffc93fd60>
body: <p>I have installed the gem </p>
  
  <pre><code>gem 'state_machine', :require =&gt; 'state_machine/core'
  </code></pre>
  
  <p>I've bundled.</p>
  
  <p>I've migrated a column state type string to the relevant Table. </p>
  
  <p>My model looks like this</p>
  
  <pre><code>  belongs_to :user
    belongs_to :patient
  
    validates :patient_id, uniqueness: {scope: [:email]}
  
    state_machine :initial =&gt; :unseen do
      event :look do  
        transition :unseen =&gt; :seen
      end
    end
  </code></pre>
  
  <p>When I ran </p>
  
  <pre><code>rails c
  Table.all
  </code></pre>
  
  <p>I got the below error in reference to the model page where I referenced state_machine</p>
  
  <pre><code>undefined method `state_machine' for Table
  </code></pre>
  
  <p>I commented out the relevant portion of the model page, deleted all the previously created records in that table, uncommented out the state_machine portion of the model, and then from within rails c I could successfully create a record but the value for state was nil.</p>
  
  <p>Equally disturbing when I try to load my front page I'm using Angular and it makes an API call to retrieve records which returns a 500 error. The console log shows</p>
  
  <pre><code>NoMethodError (undefined method `state_machine' for #&lt;Class...
  </code></pre>
  
  <p>This person (<a href="https://stackoverflow.com/questions/18099290/state-machine-gem-integration-with-rails-4">state_machine gem integration with rails 4</a>) had the same issue and needed to restart their server. I have restarted the servers several times, as well as closing terminal and then starting the servers.</p>
  
  <p>My Gemfile.lock has this file - state_machine (1.2.0), and the bundle showed no errors.</p>
  
  <p>Edit:</p>
  
  <p>Despite having been able to call Table.all successfully after deleting all previous records in that table (requiring commenting out the state machine code) and then, after uncommenting said code, being able to create and view a record, if I then leave the console and return to the console and repeat the exact same request (Table.all) it leads to the same error of undefined method 'state_machine'</p>