I have two models,Book and Picture,one book can have many pictures.
In database,I contact them by uuid column which is not a primary
key,roughly like this:
Books
Pictures
|--------------------------------- |-------------1:*(via
uuid)----------|------------------------------------|
|id | title | isbn |…|uuid
| |id|create_at|rating|…|
you can use :foreign_key like
has_many :pictures, ::foreign_key => “uuid”
or if that doesn’t work you could use the :finder_sql option
and define you own sql to find the related records.
I’m doing some work with occupational data right now and everything
has an onet_soc_code which is not the primary key. It’s not
documented, but you can do this (primary_key tells the model to use
that column as the local side for looking things up instead of the
tables real primary key).