Skip to content

Instantly share code, notes, and snippets.

View CodyFitzpatrick's full-sized avatar
🖥️
Coding or ZzZz'ing

Cody Fitzpatrick CodyFitzpatrick

🖥️
Coding or ZzZz'ing
View GitHub Profile
@CodyFitzpatrick
CodyFitzpatrick / seeds_with_sql_import.rb
Last active November 14, 2022 11:17
Ruby on Rails - Import Data via SQL in seeds.rb
# Creation of other records in Ruby above ...
connection = ActiveRecord::Base.connection
sql = File.read('db/import.sql') # Change path and filename as necessary
statements = sql.split(/;$/)
statements.pop
ActiveRecord::Base.transaction do
statements.each do |statement|