Question

My implementation was working with rails version 3.2. I am trying to upgrade my app to rails 4.1 but then I started getting error "uninitialized constant ActiveRecord::Transitions". According to transitions gem documentation on github (https://github.com/troessner/transitions) , it should work with rails >=4 without any issue.

code for active_record class with transitions is given below.

class Coupon < ActiveRecord::Base
  has_paper_trail
  include Rails.application.routes.url_helpers 
  include ActiveRecord::Transitions

  state_machine do
    state :available
    state :issued

    event :issue do
      transitions :to => :issued, :from => :available
    end
  end
end

error I am getting is

`<class:Coupon>': uninitialized constant ActiveRecord::Transitions (NameError)

Although gem is included

gem "transitions", :require => ["transitions", "active_model/transitions"]
Was it helpful?

Solution

The docs say to include ActiveModel::Transitions. What you have done is include ActiveRecord::Transitions.

Typo maybe??

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top