Specifically, let’s assume that we have two sensible models:
TieDyeCentipede, whichhas_many :legsLeg, which has a:colorattribute.
Being a TieDyeCentipede, no two legs are ever the same color. In fact, a particular leg’s color is unique among all of the legs of all of our TieDyeCentipedes.
Based on that uniqueness, we want to find a particular Centipede by a particular color of leg — let’s say :deep_sky_blue.
I could do something like:
critter = Leg.find_by_color(:deep_sky_blue).tie_dye_centipede
However, is there a find_by_* method on the TieDyeCentipede class that I could use as well?
No magic:
Some magic: