有没有人使用AASM状态机Gem with Rails 2.3.2有问题?这是工作为我好,但现在给人一种NoMethodError
:由Rails 2.3.2破坏的AASM Gem?
NoMethodError (undefined method `state' for #<Comment:0x25cb8ac>):
/usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:231:in `send'
/usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:231:in `aasm_read_state'
/usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:135:in `aasm_current_state'
/usr/local/lib/ruby/gems/1.8/gems/rubyist-aasm-2.0.5/lib/persistence/active_record_persistence.rb:156:in `aasm_ensure_initial_state'
app/controllers/comments_controller.rb:12:in `create'
下面是从我的模型相关的代码,使用AASM:
class Comment < ActiveRecord::Base
include AASM
belongs_to :post
after_create :spam_check
aasm_column :state
aasm_initial_state :submitted
aasm_state :submitted
aasm_state :approved
aasm_state :rejected
aasm_event :ham do
transitions :to => :approved, :from => [:submitted, :rejected]
end
aasm_event :spam do
transitions :to => :rejected, :from => [:submitted, :approved]
end
private
def spam_check
# Invoke Askismet to see if the comment is spam...
end
end
请注意,我在我的comments
表state
列。
- 任何想法为什么它不再有效?
我在评论表中有这一栏。 – 2009-04-10 09:52:46