How do I access universe from actor (and vice versa)?
I have three models
universe
character
actor
Universes and characters are associated via a separate join table using has_many through. Characters and actors are associated via a separate join table using has_many through.
(Note: the reason why i decided against has_and_belongs_to_many
and instead chose has_many through
is because of reasons outlined in the accepted answer Rails habtm joins )
I do not wish to store foreign keys in any of the three primary tables.
universe
\
\
universe_character_tie
/
/
character
\
\
character_actor_tie
/
/
actor
I want to somehow associate universes and actors... through characters. Two approaches come to mind:
1)
If I do a has_many through
characters
type of association, that will
- bypass the other two
has_many through
join tables; and - require foreign keys in `characters, right?
2)
Don't do anything. calling actor.character.universe
will already work... (is this true)?
I am not sure whether my haunches are correct, and I am somewhat stuck in coding it. Can someone shed light, please?