I have a model called Locality, which is basically a city (or a suburb within a big city).
Each Locality has a short list of the Localities which are adjacent – this is to help in searching.
I have read dozens of posts on here regarding self-referential has_many, :through associations and so on, but I’m still having trouble figuring this out.
Essentially what I’d like to end up with is:
l = Locality.find(1)
n = l.nearby_localities
# n should now hold a list of Locality ids
What’s the best way for this to be done?
How do you determine
nearby_localities?Actually, you could just have it a simple method.
Keep it simple!