小编Seb*_*ils的帖子

state_machine gem与rails 4集成

我正在使用我的rails 4应用程序使用state_machine gem时遇到问题.A有一个模型,其中包含列调用状态,如提供的rails教程 http://gistflow.com/posts/679-state-machine-with-rails-basics中所述

但是当我定义我的state_machine时如下:

class Issue < ActiveRecord::Base
validates :title, :description, presence: true
has_many :notes

state_machine :initial => :new do
    state :new, value: 0
    state :analysed, value: 1
    state :assigned, value: 2
    state :inprogress, value: 3
    state :inreview, value: 4
    state :validation, value: 5
    state :resolved, value: 6
    state :cancelled, value: 7
    state :closed, value: 8
    state :rejected, value: 9
    state :reopened, value: 10
end

def next
    Issue.where("id > ?", self.id).first || Issue.first
end

def prev
    Issue.where("id < ?", …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails state-machine-workflow nomethoderror

3
推荐指数
1
解决办法
2533
查看次数