Sha256: 7e0e148c848f7904cf30272530646df397d15243011944e3c78fb844877dc5b5

Contents?: true

Size: 554 Bytes

Versions: 5

Compression:

Stored size: 554 Bytes

Contents

# Extends AR to add earthdistance functionality.
require "activerecord-postgres-earthdistance/acts_as_geolocated"
module ActiveRecord
  module ConnectionAdapters
    module SchemaStatements

      # Installs hstore by creating the Postgres extension
      # if it does not exist
      #
      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
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
activerecord-postgres-earthdistance-0.4.0 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.3.2 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.3.1 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.3.0 lib/activerecord-postgres-earthdistance/activerecord.rb
activerecord-postgres-earthdistance-0.2.0 lib/activerecord-postgres-earthdistance/activerecord.rb