Sha256: 18944d9389d8e798de5214e3eb33cff530c5ccc67afe9366fda0b399618dd9e4
Contents?: true
Size: 779 Bytes
Versions: 1
Compression:
Stored size: 779 Bytes
Contents
class InscriptioCursualis::Neighborhood < InscriptioCursualis::Model self.abstract_class = true has_paper_trail belongs_to :city, class_name: '::City' belongs_to :district, class_name: '::District' has_and_belongs_to_many :streets, class_name: '::Street', join_table: :unico_neighborhoods_unico_streets validates :name, :city, presence: true validates :name, uniqueness: { scope: [:city_id, :district_id] }, allow_blank: true validate :district_must_belong_to_city delegate :state, to: :city, allow_nil: true def self.active where(inactive: false) end def to_s name end protected def district_must_belong_to_city return unless district && city errors.add(:district, :invalid) if city.districts.exclude? district end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
unico-training-7.8.0 | app/models/inscriptio_cursualis/neighborhood.rb |