Fixed the seeder loading the sql incorrectly; now stubs the index out so it generates the sequence number.

This commit is contained in:
Ron Warholic
2013-10-18 21:24:44 -04:00
parent cfeb6fd1d2
commit 93b8e3b055
2 changed files with 4 additions and 6 deletions
+4 -4
View File
@@ -14,10 +14,10 @@ end
#Load bike brands and models from sql
if BikeBrand.all.empty? and BikeModel.all.empty?
sql_path = File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')
db_config = Rails.application.config.database_configuration[Rails.env]
cmd = "psql #{db_config["database"]} < #{sql_path}"
system cmd
load_statements = File.readlines(File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')).drop(1).map do |statement|
statement.sub(/VALUES\(\d+,/, 'VALUES(DEFAULT,').tap {|x| puts x }
end
ActiveRecord::Base.connection.execute(load_statements.join)
end
if Rails.env.development?