Oh, right.. I'm new to ruby. I do remember the ! convention now.
Ok, so I figured out the issue, but the more I think about it, the more I'm confused.
so the unsent_message's user_id was nil. Once I set that to 1 (which my user object was user_id 1) then it worked great.
But then I set user.administrator = false. Now nothing works
I've gone back through the model and lifecycle and removed all requirements from both the permissions and the lifecycle from requiring admin.
The lifecycle looks like this:
lifecycle do
state :sent
state :not_sent, :default => true
transition :redeliver, {:sent => :sent}, :available_to => :all do
end
transition :deliver, {:not_sent => :sent}, :available_to => :all do
end
transition :Mark_Unsent, {:sent => :not_sent}, :available_to => :all
end
As you can see, it shouldn't care who the user is. I don't really understand what to place into :available_to for this. Especially since the script is calling it. Who is acting_user at that point? Do I set acting_user like this:
acting_user = User.first (as an example)
Or for the lifecycle is acting_user whatever user you pass into it as the first param when it's called?
What I really want to do is to enable the transition if the message.user_id is the user_id observing the record or an administrative account (or a script_user account).
Thanks all for the help!
-Brett