Forum: Ruby on Rails PostGIS and MySql Spatial Extensions in Rails

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
A262d628c2f154b8eb31626904033227?d=identicon&s=25 Guilhem Vellut (Guest)
on 2006-05-03 18:57
(Received via mailing list)

This post is to announce a new release of the Spatial Adapter for Rails,
which is a plugin that adds support for columns of geometric types
linestring, polygon,etc...) to ActiveRecord. Currently the only
databases are MySql and PostGIS.
With this release, geometric columns should behave like columns of any
basic types in all areas: migration, data access, dumping in ruby schema
For example, here is how you would define a "restaurants" table in a
migration, along with a spatial index on the geometric column:

ActiveRecord::Schema.define do
  create_table "restaurants", :force => true do |t|
    t.column "data", :string
    t.column "geom", :point, :null=>false, :srid => 123

  add_index "restaurants", "geom", :spatial=>true

Here is the model to use it:

class Restaurant < ActiveRecord::Base

And you would access the geom column in the following way:

rt = Restaurant.find_first
puts rt.geom.x #access the geom column like any other

Documentation and instructions for installation are available at .

It is distributed under the MIT license.

This topic is locked and can not be replied to.