Sha256: 43776a24ca5fe8a1ddf974229cf9430c045a5dc0551cf418427bf34f041d41fc

Contents?: true

Size: 575 Bytes

Versions: 6

Compression:

Stored size: 575 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));" % [table_name, table_name, (options[:lat] || "lat"), (options[:lng] || "lng")])
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
activerecord-postgres-earthdistance-0.7.2 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.7.1 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.7.0 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.6.0 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.5.2 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.5.1 lib/activerecord-postgres-earthdistance/activerecord.rb