Sha256: b05759b614f5a8735adcf035ef1cc6de81044127e5e8ef62fced2a5623e2cce6

Contents?: true

Size: 598 Bytes

Versions: 1

Compression:

Stored size: 598 Bytes

Contents

# Extends AR to add earthdistance functionality.
require "activerecord-postgres-earthdistance/acts_as_geolocated"
module ActiveRecord
  module ConnectionAdapters
    module SchemaStatements
      def add_earthdistance_index(table_name, options = {})
        execute("CREATE INDEX %s_earthdistance_ix ON %s USING gist (ll_to_earth(%s, %s));")
          .format([table_name, table_name, (options[:lat] || "lat"), (options[:lng] || "lng")])
      end

      def remove_earthdistance_index(table_name)
        execute("DROP INDEX %s_earthdistance_ix;").format([table_name])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
activerecord-postgres-earthdistance-0.5.0 lib/activerecord-postgres-earthdistance/activerecord.rb