Given the following models:

Job.many_to_one :worker
Job.many_to_one :schedule

Worker.one_to_many :work_order

WorkOrder.many_to_one :worker
WorkOrder.many_to_one :schedule

A Schedule represents a timeframe, for example one week, and a WorkOrder 
represents all the jobs for a specific worker for that specific schedule.

It's easy enough to write a query for all the jobs that belong to a 
specific work order:

Job.where(schedule: work_order.schedule, worker: work_order.worker)

...and from the docs 
(http://sequel.jeremyevans.net/rdoc/files/doc/association_basics_rdoc.html) 
it looks like you should be able to do this:

WorkOrder.one_to_many :jobs, key: [:worker_id, :schedule_id]
Job.many_to_one :work_order, key: [:worker_id, :schedule_id]

But when trying this I get:

mismatched number of keys: [:worker_id, :schedule_id] vs [:id] 
(Sequel::Error)

So, can you write an association like this, and if so how so?

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to