views:

23

answers:

1

Hello,

I have installed multiple state_machine gems to my app to use them for a notification system but every time I run into an ActiveSupport issue. It usually looks something almost identical to this:

>> 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

I'm on a windows 7 machine using activerecord, bundler to install the gems, and rails 2.3.9..where am I going wrong? Is there some modification to the database I need to be making?

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

I'm not positive, but I am having trouble adapting this for activerecord. do i need to create a new database?

A: 

EDIT

I ended up just using oldschool acts_as_state_machine since this is such a simple implementation

Ryan Max