我的设置: Rails 3.0.9,Ruby 1.9.2
似乎有几个状态机宝石在那里,acts_as_state_machine,state_machine,转换,工作流,aasm。开发人员使用最多的是什么?
发布于 2011-07-26 06:14:56
据ruby-toolbox.com称,最受欢迎的是aasm。
更新。现在最流行的是state_machine,但是你知道去哪里找它。
发布于 2012-02-11 15:41:16
我知道你很久以前就问过这个问题,但还没有接受回答。
从Rails3开始,现在有了一个单独的gem。我建议你读一读这篇小博文
http://dev.netizer.pl/transitions-state-machine-for-rails-3.html
示例:
class Project < ActiveRecord::Base
include ActiveRecord::Transitions
# default field name is 'state',
# but if you want 'status'
# you can write "state_machine :status do" instead
state_machine do
state :started # first one is initial state
state :finished
end
endhttps://stackoverflow.com/questions/6822943
复制相似问题