finds.dev

rgeo/activerecord-postgis-adapter

ActiveRecord connection adapter for PostGIS, based on postgresql and rgeo

View on GitHub

★ 937RubyNOASSERTIONupdated Apr 2026

// the take

A Rails ActiveRecord adapter that lets you use PostGIS spatial types (points, polygons, linestrings) as first-class columns, backed by the RGeo geometry library. If you're building a Rails app that needs to store and query geographic data in PostgreSQL, this is the standard way to do it. It's been around since Rails 3 and tracks ActiveRecord releases closely.

The version compatibility table goes all the way back to Rails 3 and up through AR 8.1, which is unusually disciplined maintenance for a niche adapter. Spatial columns integrate naturally into migrations — `t.st_point :lonlat, geographic: true` works exactly like any other column type. The Arel extension for spatial predicates (`buildings[:geom].st_contains(point)`) means you can build spatial WHERE clauses without dropping into raw SQL strings. Factory configuration via `SpatialFactoryStore` gives you real control over coordinate systems without polluting model code.

The join limitation is a real papercut: when you join a spatial model to another table, SRID and geographic flag are lost and you have to manually redeclare attributes on the parent model — easy to forget, produces wrong results silently. WKT parse failures currently set the value to nil with no error, which is a silent data loss trap (the README acknowledges this will change, but it hasn't yet). The adapter is tightly coupled to RGeo, so if you want a lighter dependency or a different geometry library you're out of luck. There's no built-in support for spatial query helpers beyond `st_contains`; anything more complex (nearest-neighbor, within-distance) means writing raw PostGIS SQL.

We read the README, the directory tree and a key source file in June 2026. Nobody pays to be listed. How we judge →

// at a glance

Stars
937
Forks
258
Language
Ruby
License
NOASSERTION
Last commit
16 Apr 2026

// nearby

If activerecord-postgis-adapter isn't quite it.

All repos →