Use a validation. If you don't want duplicate records, validate the uniqueness of one or more fields. In you town_health_record.rb
class TownHealthRecord
validates_uniqueness_of :city
validates uniqueness_of :health, scope: :person # If you wanted to validate a combination of fields
end
On an added side not, .create!
will raise errors. .create
will not. Same goes for save!
and .update_attributes!
.