Sha256: a83e1ae6b369304e9ce55fbd16879e66b32196706f03187c5f8cf2cc0ce7169c
Contents?: true
Size: 467 Bytes
Versions: 1
Compression:
Stored size: 467 Bytes
Contents
class City < ActiveRecord::Base belongs_to :country has_many :people validates :name, :presence => true validates :country, :presence => true before_destroy :protect_with_inhabitants default_scope includes(:country).order('countries.code, cities.name') def to_s "#{name} (#{country.code})" end protected def protect_with_inhabitants if people.exists? errors.add(:base, :protect_with_inhabitants) false end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
dry_crud-1.5.0 | test/templates/app/models/city.rb |