Belongs_to primary key

I’m writing a rails application that uses a legacy database that is
imported. The legacy database has primary keys like “appno”. The new
structure in rails is going to be “id, company_id, appno” so there may
be more than one record with the same appno, but each having a unique
company_id, appno pair. id will be completely unique.

The joined record will have the structure “id, company_id, jobno, appno”
where company_id and jobno form a unique pair, and id is unique. I want
to say that the job belongs_to :applicant, :foreign_key => “appno”,
:primary_key => “appno”, :conditions => [“company_id = ?”,
self.company_id] so that it won’t use the id field on the applicant
record but will instead use the appno field. Is it possible to do this?

Jeremy W.
Serval Systems Ltd.

www.servalsystems.co.uk http://www.servalsystems.co.uk
Tel: 01342 331940
Fax: 01342 331950