class AvailabilityZone < ActiveRecord::Base has_many :servers, inverse_of: :availability_zone has_many :volumes, inverse_of: :availability_zone before_validation :set_region def set_region self.region = self.name.gsub(/[a-z]$/, '') end end