Skip to content

Instantly share code, notes, and snippets.

@franciscoj
Created May 12, 2011 10:15
Show Gist options
  • Save franciscoj/968283 to your computer and use it in GitHub Desktop.
Save franciscoj/968283 to your computer and use it in GitHub Desktop.
Seed the database using sql files
# db/seeds.rb
Dir.glob("#{base_dir}/*.sql").each do |file_name|
puts "Seeding #{ file_name }"
sql_file = File.new(file_name)
while statements = sql_file.gets("") do
ActiveRecord::Base.connection.execute(statements)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment