Lifecycle in Hobo 3

13 views
Skip to first unread message

Tiago Franco

unread,
Jan 18, 2011, 5:26:14 PM1/18/11
to hobo...@googlegroups.com
Hi,

I have the following lifecyle:

-----------------------------------------------------
belongs_to :user, :creator => true

lifecycle do

state :requested, :purchased, :payed

create :request, :available_to => "User",
:become => :requested,
:user_becomes => :user,
:new_key => true

...
------------------------------------------------

When I try to create a model in the console with:

CreditTransaction::Lifecycle.request User.first

I get the following error:

ActiveRecord::AssociationTypeMismatch: User expected, got User
from
/home/tfranco/.rvm/gems/ruby-1.9.2-p136/bundler/gems/hobo-44c62e844f88/hobo/lib/hobo/extensions/active_record/associations/proxy.rb:19:in
`raise_on_type_mismatch'
from
/home/tfranco/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/associations/belongs_to_association.rb:23:in
`replace'
from
/home/tfranco/.rvm/gems/ruby-1.9.2-p136/gems/activerecord-3.0.3/lib/active_record/associations.rb:1474:in
`block in association_accessor_methods'
from
/home/tfranco/.rvm/gems/ruby-1.9.2-p136/bundler/gems/hobo-44c62e844f88/hobo/lib/hobo/model/accessible_associations.rb:152:in
`user_with_finder='

...

What am I doing wrong?

Thanks,
Tiago Franco

Tomoaki Hayasaka

unread,
Jan 18, 2011, 6:23:26 PM1/18/11
to hobo...@googlegroups.com, gama....@gmail.com
From: Tiago Franco <gama....@gmail.com>
Subject: [Hobo Users] Lifecycle in Hobo 3
Date: Tue, 18 Jan 2011 22:26:14 +0000

> When I try to create a model in the console with:
>
> CreditTransaction::Lifecycle.request User.first
>
> I get the following error:
>
> ActiveRecord::AssociationTypeMismatch: User expected, got User

It's an issue of 1.3.0pre. Sometimes "User" means Hobo::Model::User,
not your User.

Try replacing "User" with "::User":

- create :request, :available_to => "User",
+ create :request, :available_to => "::User",

-----
Tomoaki Hayasaka <haya...@pfsl.mech.tohoku.ac.jp>

Reply all
Reply to author
Forward
0 new messages