This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# db/seed.rb | |
# This block will automatically empty the database every time db:seed is run. | |
ActiveRecord::Base.connection.tables.each do |table| | |
# Don't clear our migration history! Clear everything else. | |
if table != 'schema_migrations' | |
# http://stackoverflow.com/a/7758797 | |
ActiveRecord::Base.connection.execute("TRUNCATE TABLE #{table};") | |
# http://stackoverflow.com/questions/2097052/rails-way-to-reset-seed-on-id-field | |
ActiveRecord::Base.connection.reset_pk_sequence! table |