module Logistics module Core class InterCityRoute < Route validates :from_id, :to_id, presence: true, allow_blank: false validates :from_id, uniqueness: {scope: [:from_id, :to_id]} validate :check_from_id_and_to_id def check_from_id_and_to_id errors.add(:from_id, "can't be the same as to.") if from_id == to_id end end end end