There are several options for rendering or displaying geospatial objects within a Rails application. Usually the hardest part is setting up your application to be able to store geospatial data and run PostGIS related functions with it.
I'm not sure where you are at in your process of using Rails with PostGIS, so as long as you have already installed PostGIS, GEOS, and PROJ.4, I recommend you add and setup the following gems in your Rails application:
- RGeo - Geospatial data library for Ruby. At its core is an implementation of the industry standard OGC Simple Features Specification, which provides data representations of geometric objects such as points, lines, and polygons, along with a set of geometric analysis operations.
- PostGIS ActiveRecord Adapter - The activerecord-postgis-adapter provides access to features of the PostGIS geospatial database from ActiveRecord.
- RGeo::GeoJSON - RGeo::GeoJSON is an optional module for RGeo that provides GeoJSON encoding and decoding services. This is handy for outputting your geospatial data into a format that is supported for loading onto most of the major mapping systems.
After you have those gems (and their prerequisite software packages) installed and setup, you are ready to store and access geospatial data within your Rails application. Now you will need to decide how you want to render and display the data on a map. Options for this include:
- Directly using JavaScript libraries and APIs like Google Maps, LeafletJS, etc. This will be the most flexible option and support the most mapping systems. You just need to determine how to output your data in a format that is supported by your API of choice (like GeoJSON).
- Using gems that provide tighter integration with your Rails app like Google Maps for Rails