I have Events, Documents, and Surveys which all need to be able to link to one another, I was planning on having a linking table with four columns as follows:
link_elements{
element1_type CHAR(1)
element1_id INTEGER
element2_type CHAR(1)
element2_id INTEGER
}
The problem is I can't figure out how to make the model in RoR so that I can use the element type field to identify which table the corresponding element id belongs to (Documents, Events, or Surveys). I'm really new to Ruby and any help would really be appreciated.