views:

29

answers:

0

Hi,

I am having a bit of trouble with the 'workflow' gem, namely, the transitions aren't working.

What I am trying to do is very basic, I have a 'read/unread' state for messages between users, the transition is triggered when the user goes to a 'show' page for that specific message. However, I can't seem to get the transition to work, even in the console:

\\ message.rb

class Message < ActiveRecord::Base
    include Workflow

    workflow do
        state :unread do
          event :view, :transitions_to => :read
        end
        state :read
    end
end

in the console, when I try to make this transition, I use the following code and get the following output:

>> message = Message.new
=> #<Message id: nil, user_id: nil, message: nil, created_at: nil, u
pdated_at: nil>
>> message.current_state
=> #<Workflow::State:0x7ed4febc @name=:unread, @events={:view=>#<Workflow:
:Event:0x7ed4fd90 @action=nil, @name=:view, @transitions_to=:read, @meta={}
>}, @meta={}>
>> message.unread?
=> true
>> message.view!
NoMethodError: undefined method `workflow_state=' for #<Message:0x7ecfd5a4>
        from /home/Ryan/.bundle/ruby/1.8/gems/activerecord-2.3.8/lib/active_reco
rd/attribute_methods.rb:259:in `method_missing'
        from /home/Ryan/.bundle/ruby/1.8/gems/activerecord-2.3.8/lib/active_reco
rd/base.rb:2656:in `send'
        from /home/Ryan/.bundle/ruby/1.8/gems/activerecord-2.3.8/lib/active_reco
rd/base.rb:2656:in `update_attribute'
        from /home/Ryan/.bundle/ruby/1.8/gems/workflow-0.7.0/lib/workflow.rb:272
:in `persist_workflow_state'
        from /home/Ryan/.bundle/ruby/1.8/gems/workflow-0.7.0/lib/workflow.rb:211
:in `transition'
        from /home/Ryan/.bundle/ruby/1.8/gems/workflow-0.7.0/lib/workflow.rb:165
:in `process_event!'
        from /home/Ryan/.bundle/ruby/1.8/gems/workflow-0.7.0/lib/workflow.rb:124
:in `view!'
        from (irb):25

I can't find ANYTHING about what is going on here, from googleing and even tried looking in: /home/Ryan/.bundle/ruby/1.8/gems/workflow-0.7.0/lib/workflow.rb but I can't see any reason this isn't working. This is a really simple problem and I've wracked my brain figuring out what is wrong.

Thanks for your help