Is there such a thing? I am thinking of an application that has
something like this:
-
person has many things - there is a ‘persons’ table
-
the things he has are stored in a table that is something like this
person_id, thing_table_name, thing_id
For example, it may map to
person1, books, 23 #Person 1 owns book 23
person1, books, 25 #Person 1 owns book 25
person1, chair, 23 #Person 1 owns chair 23
person1, books, 30
person2, books, 19
person2, books, 31 #Person 2 owns book 31
… and so on… -
A number of tables for different ‘things’…
books - table for books
chairs - table for chairs
and so on…
Ideally I want to have something which means “person
has_and_belongs_to_many_different things”
I guess it could be implemented by manually looking at the 2nd table to
find the foreign key and table that it refers to and then do a find from
the specific table for the specific ID. But, I’m trying to find a
better “Railsy” way.
Cheers
Mohit.