Run a rake db:seed multiple times without creating duplicate records? [duplicate]
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 fieldsend
On an added side not, .create!
will raise errors. .create
will not. Same goes for save!
and .update_attributes!
.