Linking different Models together and walking them dynamical


#1

Hey all,
I’m doing something of a node-node connection, and I want to
eventually walk each node, pulling data from each node, and displaying
the path. The DB table would just be columns of IDs that link to each
other

My catch is that these aren’t generic nodes, they are Models that
could potentially connect to each other, and I don’t know how to
‘walk’ from one to another dynamically. They have enough unique
properties to warrant their own tables.

I was thinking of creating a column called ‘type’ and having that be
the name of the Model/Class, and make Ruby call that class, but I
don’t know if Ruby can inject a variable and use it as a name

So, obj1 connects to obj3 connects to obj2

obj2 is of Model ‘x’,
obj1 is of Model ‘y’,
obj3 is of Model ‘z’.

And the columns would be: src | dest | src_type | dest_type

Where src_type (and dest_type) is the name of a Model

Any ideas on how to do this? Any speculations would be welcomed as I am
stuck!

  • Nic