Sha256: 7a0b6f71051707b6312c2e4f60b270220e669916530dcaeeea0d247f63749edc
Contents?: true
Size: 477 Bytes
Versions: 2
Compression:
Stored size: 477 Bytes
Contents
class City < ActiveRecord::Base has_many :people validates :name, :presence => true validates :country_code, :presence => true before_destroy :protect_with_inhabitants default_scope order('country_code, name') def label "#{name} (#{country_code})" end protected def protect_with_inhabitants if people.exists? errors.add(:base, "You cannot destroy this city as long as it has any inhabitants") false end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
dry_crud-1.2.7 | test/templates/app/models/city.rb |
dry_crud-1.2.6 | test/templates/app/models/city.rb |