Hi, I was wondering if somebody has any pointer for me.
Here is what I have and trying to do.
Let's say I have 2 models
WorkOrder ( id, ref_number, desc) ( and a bunch of other fields)
OldRma ( id, ref_number, customer_data)
Work order is a big table that has all the info about the work order,
Old rma contains older data, that is still imported from customer that
needs to be referenced. Both models hav id as a primary field that can't
be changed ( so I can't make ref_number a primary key in either table)
ref_number field is unique for OldRma, and there might be multiple
WorkOrders with the same ref_number.
I need to be able to reference both tables and run find statements with
At first I wanted to change primary key on OldRma, but that is not an
option as that field id is already used in other models.
I was able to add to WorkOrder
class WorkOrder < ActiveRecord::Base
So I can do:
w = WorkOrder.find_by_ref_number(5)
Which kind of lets me have shortcuts for finding data.
But what I need to do is
w = WorkOrder.find(:all, :conditions => "work_orders.ref_number = 1234",
:include = > :oldrma )
This obviously breaks cause there is no direct association between two
belongs_to with a foreign_key - won't work cause I can't change the
primary keys on models. Rails doesn't support secondary keys. So can
somebody suggest a way to do it?