2010-10-07 37 views
1

我已经安装了多个state_machine宝石到我的应用程序使用它们的通知系统,但每次遇到ActiveSupport问题。它通常看起来这种事情几乎相同:Rails 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/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 

我是Windows 7机器上使用ActiveRecord,捆绑安装的宝石,和Rails我要去2.3.9..where错了吗?我需要对数据库进行一些修改吗?

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。我需要创建一个新的数据库吗?

+0

我们需要更多信息行,你回答类,其中引发错误 – shingara 2010-10-07 08:47:01

+0

编辑的问题,包括message.rb(对不起,忘了把它从答案改为消息!)...它对于我尝试过的所有状态机(几乎所有这些状态机)都是这个代码的几个变体......正如你所看到的,我使用因为它非常简单。 – goddamnyouryan 2010-10-07 08:54:43

回答

0

编辑

最后我只是用旧校园acts_as_state_machine,因为这是这样一个简单的实现