I’ve done this in other languages, but how would you handle the
following issue in Rails?
Assume database tables a, b and c.
Each table has id,name,text fields
(and yes, there are reasons why they are separate tables -
I’m simplifying here)
Any record in any table can cross-reference one or more records
in that table or another table. The cross reference tables are
a_a, a_b, a_c, b_b, b_c, c_c [fields are as expected a_id,b_id, etc)
So assume record 1 in table a is referenced by:
record 22 in table a
record 347 in table b and
record 19 in table c.
When a record is displayed, I have a dropdown select box that shows
the name of any cross references. The contents are generated by a
database view created by multiple selects combined with union.
The obvious hurdle in a select box is returning not just the id of the
selected item, but also the table in which that particular item is
In my current (non-ruby, non-rails) implementation, this is solved by
concatenating the table name with a separator and the record id
The select box thus returns the combined value which is then exploded
into its parts so that the webapp can display the desired item. This
isn’t difficult when done manually, but what would be the appropriate
way of handling the issue in the “Rails” way?