Avoid duplicate entries created with seeds.rb?
I have the following code in mine
to create an entry in my simple Rails application.
Post.create( title: "Unique Title!", body: "this is the most amazingly unique post body ever!" )
When running the command
, obviously the db seeds with this data. How to add validation or protection to the code so that it is included only once, i.e. How unique? If I restart
, I don't want to add this same entry again.
source to share