class Bed < ApplicationRecord belongs_to :care_centre belongs_to :patient, optional: true scope :available, -> { where(patient: nil) } def available? patient.blank? end end