Browse Source

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

topic-sass
Ron Warholic 11 years ago
parent
commit
93b8e3b055
  1. 2
      Gemfile.lock
  2. 8
      db/seeds.rb

2
Gemfile.lock

@ -162,7 +162,6 @@ GEM
rdoc (~> 3.4) rdoc (~> 3.4)
thor (>= 0.14.6, < 2.0) thor (>= 0.14.6, < 2.0)
rake (10.0.4) rake (10.0.4)
rb-fsevent (0.9.3)
rdoc (3.12.2) rdoc (3.12.2)
json (~> 1.4) json (~> 1.4)
rspec (2.8.0) rspec (2.8.0)
@ -242,7 +241,6 @@ DEPENDENCIES
pg pg
pry (~> 0.9.8) pry (~> 0.9.8)
rails (= 3.2.13) rails (= 3.2.13)
rb-fsevent
rspec-rails (~> 2.8.1) rspec-rails (~> 2.8.1)
shoulda-matchers (~> 1.0.0) shoulda-matchers (~> 1.0.0)
spork spork

8
db/seeds.rb

@ -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?

Loading…
Cancel
Save