mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
11 lines
305 B
Ruby
11 lines
305 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Country < ApplicationRecord
|
|
validates :name, :iso_a2, :iso_a3, :geom, presence: true
|
|
|
|
def self.containing_point(lon, lat)
|
|
where("ST_Contains(geom, ST_SetSRID(ST_MakePoint(?, ?), 4326))", lon, lat)
|
|
.select(:id, :name, :iso_a2, :iso_a3)
|
|
.first
|
|
end
|
|
end
|