For each movie in MovieDB, we want to track which other movie it was inspired by. For example:
Start by adding a field Movie#inspiration_id
. In the movie form, I should be able to select the inspiring movie.
The list should:
In the movie show view, I want to see the "inspiration tree" of that movie.
An inspiration tree for a movie M
could look like this:
stateDiagram-v2
M: (M)
A --> B
B --> M
M --> C
M --> D
D --> F
D --> E
In the tree above I can see:
M
was inspired by B
B
was inspired by A
A
has no recorded inspirationC
and D
were inspired by M
F
and E
were inspired by D
Note that if an ancestor B has inspired other movies than the current movie M, we do not need to display it.
Look at your development log while opening a movie. How many queries are triggered?
Movie#inspiration_id
to the materialized path pattern using the
ancestry gem
Show archive.org snapshot
.ancestry
is triggering. How does it work?