Have you ever seen this table structure?

Im wondering how I can define the following table structure from a legacy DB in Rails.

If I have three tables, tables A, B and C. And in table A, I have an integer field, call it 'B_or_C_id' and also an integer field in table A called 'you_must_use_C' which, if -1 means

A.B_or_C_id = C.id

and if 0 means

A.B_or_C_id = B.id

How in the world do you define this in ActiveRecord in terms of 'belongs_to,' and 'has_many'

Thanks, Ralph Vince

It looks like you may need to have a base class A and 2 subclasses of A corresponding to 2 types. Something like AWithB and AWithC, which both subclass A. (and put all the has_many and belongs_to stuff that relates to C and B in the subclasses)

It seems I should be able to use 'conditions' ion the has_many and belongs to, yes?