|
@ -14,10 +14,10 @@ end |
|
|
|
|
|
|
|
|
#Load bike brands and models from sql |
|
|
#Load bike brands and models from sql |
|
|
if BikeBrand.all.empty? and BikeModel.all.empty? |
|
|
if BikeBrand.all.empty? and BikeModel.all.empty? |
|
|
sql_path = File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql') |
|
|
load_statements = File.readlines(File.join(Rails.root, 'db', 'seed', 'sql', 'bike_brands_and_models.sql')).drop(1).map do |statement| |
|
|
db_config = Rails.application.config.database_configuration[Rails.env] |
|
|
statement.sub(/VALUES\(\d+,/, 'VALUES(DEFAULT,').tap {|x| puts x } |
|
|
cmd = "psql #{db_config["database"]} < #{sql_path}" |
|
|
end |
|
|
system cmd |
|
|
ActiveRecord::Base.connection.execute(load_statements.join) |
|
|
end |
|
|
end |
|
|
|
|
|
|
|
|
if Rails.env.development? |
|
|
if Rails.env.development? |
|
|