Rails ActiveSupport使用状态gems发出通知问题

时间:2010-10-07 08:13:13

标签: 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/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

我在使用activerecord的Windows 7机器上,使用bundler来安装宝石,并使用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时遇到了麻烦。我需要创建一个新数据库吗?

1 个答案:

答案 0 :(得分:0)

修改

我最后只使用oldschool acts_as_state_machine,因为这是一个如此简单的实现