[英]AASM Gem broken by Rails 2.3.2?
Has anyone had any problems using the AASM state machine Gem with Rails 2.3.2? 有人在Rails 2.3.2中使用AASM状态机Gem时遇到任何问题吗? It was working fine for me but is now giving a NoMethodError
: 它对我来说工作正常,但现在给出了NoMethodError
:
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'
Here's the relevant code from my model that uses AASM: 这是我的使用ASM的模型中的相关代码:
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
Note that I have the state
column in my comments
table. 请注意,我的comments
表中有“ state
列。
Uh, you need a field in your comments table called 'state'. 嗯,您在注释表中需要一个名为“状态”的字段。 You defined it using aasm_column :state
. 您使用aasm_column :state
定义了它。 This is not a Rails 2.3.2 bug! 这不是Rails 2.3.2的错误! :D :d
From the aasm home page it appears that, as at time of writing, there's an update coming... 从aasm主页看来,在撰写本文时,有一个更新在...
There's a little discussion on the Ruby on Rails group - I don't know if any of that helps. 关于Ruby on Rails小组有一些讨论-我不知道这有没有帮助。
Executing 执行
gem list .*aasm --remote
threw up a bunch of references: 提出了大量参考:
aasmith-yodlee (0.0.1.20090301132701)
bloom-aasm (2.0.3)
bloom-bloom-aasm (2.0.3)
caleb-aasm (2.0.2)
dunedain289-aasm (2.1.3)
dvdplm-aasm (2.0.6)
eric-aasm (2.0.4)
factorylabs-aasm (2.0.5.2)
gvaughn-aasm (2.0.4)
lostboy-aasm (2.0.5.1)
mikowitz-aasm (2.0.6)
netguru-aasm (2.0.6)
notch8-aasm (2.0.5)
rubyist-aasm (2.0.5)
runcoderun-aasm (2.0.5.1)
snoozer05-aasm (2.0.2)
spicycode-aasm (2.0.0)
It suspect that some or all of the "dvdplm-", "factorylabs-" and "runcoderun-" ones may be git forks. 它怀疑“ dvdplm-”,“ factorylabs-”和“ runcoderun-”中的某些或全部可能是git fork。 You may find that one or more fixes your problem. 您可能会发现一个或多个解决了您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.