test/templates/app/models/city.rb in dry_crud-1.4.0 vs test/templates/app/models/city.rb in dry_crud-1.5.0
- old
+ new
@@ -1,17 +1,18 @@
class City < ActiveRecord::Base
+ belongs_to :country
has_many :people
validates :name, :presence => true
- validates :country_code, :presence => true
+ validates :country, :presence => true
before_destroy :protect_with_inhabitants
- default_scope order('country_code, name')
+ default_scope includes(:country).order('countries.code, cities.name')
def to_s
- "#{name} (#{country_code})"
+ "#{name} (#{country.code})"
end
protected
def protect_with_inhabitants
\ No newline at end of file