未初始化的常量ActiveRecord :: Transitions with rails 4.1和transitions gem

时间:2014-05-15 06:11:28

标签: ruby-on-rails ruby-on-rails-4 ruby-on-rails-4.1

我的实现正在使用rails 3.2版。我正在尝试将我的应用程序升级到rails 4.1但后来我开始收到错误“未初始化的常量ActiveRecord :: Transitions”。根据github(https://github.com/troessner/transitions)上的过渡gem文档,它应该与rails> = 4一起使用,没有任何问题。

带有转换的active_record类的代码如下所示。

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

我得到的错误是

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

虽然包含了宝石

gem "transitions", :require => ["transitions", "active_model/transitions"]

1 个答案:

答案 0 :(得分:0)

文档对include ActiveModel::Transitions说。你所做的是include ActiveRecord::Transitions

错字可能??