dawarich/app/models/visit.rb

18 lines
425 B
Ruby
Raw Normal View History

2024-07-21 14:32:29 -04:00
# frozen_string_literal: true
class Visit < ApplicationRecord
belongs_to :area
belongs_to :user
has_many :points, dependent: :nullify
2024-07-24 14:25:16 -04:00
validates :started_at, :ended_at, :duration, :name, :status, presence: true
2024-08-05 15:23:08 -04:00
enum status: { suggested: 0, confirmed: 1, declined: 2 }
delegate :name, to: :area, prefix: true
def coordinates
points.pluck(:latitude, :longitude).map { [_1[0].to_f, _1[1].to_f] }
end
2024-07-21 14:32:29 -04:00
end