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