module Garage
  module Vehicle
    extend ActiveSupport::Concern
    # All the Vehicle code is still here
  end

  class Car < ApplicationRecord
    include Garage::Vehicle

    has_one(
      :key,
      # This line is how we make sur to look up both values for the association
      -> { unscope(where: :vehicle_type).where(vehicle_type: ["car", "Car"]) }, 
      as: :vehicle
    )
  end
  
  class Boat < ApplicationRecord
    include Garage::Vehicle

    has_one(
      :key,
      # This line is how we make sur to look up both values for the association
      -> { unscope(where: :vehicle_type).where(vehicle_type: ["boat", "Boat"]) }, 
      as: :vehicle
    )
  end
end