On Tuesday, January 29, 2013 12:42:18 PM UTC-8, szczepan wrote: > > 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 >
Your association is called user, so you should be doing: p.user = u What you are currently doing is trying to set the foreign key (an integer column) to a User instance, and Sequel rightly complains about that. Thanks, Jeremy -- 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.
