Given the models Country, State, City and Person as follows.
class Country < ActiveRecord::Base
has_many :states
end
class State < ActiveRecord::Base
belongs_to :country
has_many :cities
end
class City < ActiveRecord::Base
belongs_to :state
has_many :people
end
class Person < ActiveRecord::Base
belongs_to :city
end
Is there any way that doesn’t allow to delete a country if it has
states?
(will do the same for states and cities, cities and persons).
Didn’t saw nothing like that in the dependent option.
Thanks in advance.