I am using seed.rb to populate both my development and production database. I usually populate the first with dummy data and the latter with the real minimal data that my app ne
another approach, quite similar to @fabro's answer:
add a folder seeds to db/
with the environment names and another named common.rb, so you get something like:
db/seeds/common.rb
db/seeds/development.rb
db/seeds/staging.rb
db/seeds/production.rb
than, in your seed.rb
:
ActiveRecord::Base.transaction do
['common', Rails.env].each do |seedfile|
seed_file = "#{Rails.root}/db/seeds/#{seedfile}.rb"
if File.exists?(seed_file)
puts "- - Seeding data from file: #{seedfile}"
require seed_file
end
end
end
I perfer running the seed in one transaction