I have the following code in my seeds.rb used to create a record in my basic Rails app via seeding.
Post.create( title: "Unique Title!", body: "this is the most amazingly unique post body ever!" )
When running the rake db:seed command, it obviously seeds the db with this data. My question is how do I add a check or safeguard in the code so that it only enters that once, i.e. as a unique? If I rerun rake db:seed, I don't want add that same entry again.
Thanks
Aucun commentaire:
Enregistrer un commentaire