The schema:
DB.create_table :projects do
        primary_key :id
        foreign_key :creator, :users
end
DB.create_table :users do
        primary_key :id
end

The model:
class Project < Sequel::Model
        many_to_one :user, :key=>:creator
end
class User < Sequel::Model
        one_to_many :projects, :key=>:creator
end

When I try to assign an user to a project:
p=Project.new.save
u=User.new.save
p.creator=u

and I get errors:

Sequel::InvalidValue: TypeError: can't convert User into Integer
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/database/misc.rb:399:in
 
`Integer'
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/database/misc.rb:399:in
 
`typecast_value_integer'
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/database/misc.rb:283:in
 
`typecast_value'
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/model/base.rb:1836:in
 
`typecast_value'
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/model/base.rb:947:in
 
`[]='
        from 
/home/sbed/www/.ruby/gems/1.9/gems/sequel-3.42.0/lib/sequel/model/base.rb:676:in
 
`creator='
        from (irb):28
        from /usr/local/ruby-1.9/bin/irb:12:in `<main>'

What is wrong? With default column name (i.e. :user_id) everything is OK.

Regards,
Szczepan

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to