Ruby on rails Rails ActiveSupport存在通知状态gems问题
我在我的应用程序中安装了多个state_machine gems,用于通知系统,但每次遇到ActiveSupport问题时。它通常看起来与此几乎相同:Ruby on rails Rails ActiveSupport存在通知状态gems问题,ruby-on-rails,database,activerecord,rubygems,Ruby On Rails,Database,Activerecord,Rubygems,我在我的应用程序中安装了多个state_machine gems,用于通知系统,但每次遇到ActiveSupport问题时。它通常看起来与此几乎相同: >> m = Message.new TypeError: wrong argument type nil (expected Module) from /home/Ryan/appname/app/models/message.rb:2:in `include' from /home/Ryan/app
>> m = Message.new
TypeError: wrong argument type nil (expected Module)
from /home/Ryan/appname/app/models/message.rb:2:in `include'
from /home/Ryan/appname/app/models/message.rb:2
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:406:in `load_without_new_constant_marking'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:406:in `load_file'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:547:in `new_constants_in'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:405:in `load_file'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:285:in `require_or_load'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:451:in `load_missing_constant'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:106:in `rake_original_const_missing'
from /usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2503:in `const_m
issing'
from /home/Ryan/.bundle/ruby/1.8/gems/activesupport-2.3.9/lib/active_sup
port/dependencies.rb:118:in `const_missing'
from (irb):2
我在Windows7机器上使用activerecord、bundler安装gems和rails 2.3.9..我哪里出了问题?我需要对数据库进行一些修改吗
Edit: message.rb
include AlterEgo # include this first
include AlterEgo::ActiveRecordAdapter
state :unread, :default => true do
handle :state do
"unread"
end
transition :to => :read, :on => :view!
end
state :read do
handle :state do
"read"
end
end
我不是很肯定,但我很难将其应用于activerecord。是否需要创建新数据库?编辑
最后,我只是使用了oldschool acts作为状态机,因为这是一个非常简单的实现我们需要更多的信息行您的答案类,其中出现错误编辑问题以包括message.rb(抱歉,忘记将其从答案更改为message!)…对于我尝试过的所有状态机(几乎所有的状态机)…这段代码都有几个变体…正如您所看到的,我对它的使用非常简单。