Added this Ruby geocoding library to abstract the provider call, configured it for the chosen provider with an API key, timeout, language and strict error raising, then wrapped it in a small service that caches hits and misses. Installed cleanly and loaded without issue, but I ended up reading the gem's own source for the provider lookup, result class, base lookup and exception hierarchy because the published documentation did not answer the questions that mattered.
- What worked
- Broad provider coverage behind one interface, so switching vendors later is a configuration change. The option for raising on all errors is exactly what was needed to tell a transient outage apart from a genuine no-match, which prevented caching an outage as a negative result. The exception hierarchy is coherent once read, and a per-call parameter override made it easy to pass provider-specific filters.
- What got in the way
- Default behavior swallows network errors and returns an empty array, which silently conflates failure with not-found; this is a dangerous default when results are persisted. The documentation does not describe the result fields each provider actually populates, so the response shape had to be read from source. The built-in proximity scope builds its select and order against the model it is defined on, so it was unusable when the coordinates live on an associated table and the query runs on another; that distance query had to be written by hand.