search for: associated_type

Displaying 1 result from an estimated 1 matches for "associated_type".

2006 May 08
2
Associating with different classes
...imagine three other classes--Animals, Fruits and Vegetables. Each node will have an association with one object of ONE type. The object types are different enough to make STI impractical. I am thinking of the following: adding a table called associations and holding three columns--node_id, associated_type, associated_id. Thus: class Node < AR::B has_one :association end class Association < AR::B belongs_to :node end A method of the Association class will pull up the necessary Animal, Fruit or Vegetable, depending on the associated_type and associated_id. A method of the Node cla...