module Conjoin::Seeds
Public Class Methods
load_sql_dump_for(dump)
click to toggle source
# File lib/conjoin/seeds.rb, line 12 def load_sql_dump_for dump connection = ActiveRecord::Base.connection connection.execute("TRUNCATE #{dump};") # - IMPORTANT: SEED DATA ONLY # - DO NOT EXPORT TABLE STRUCTURES # - DO NOT EXPORT DATA FROM `schema_migrations` sql = File.read("db/dumps/#{dump}.sql") statements = sql.split(/;$/) statements.pop # the last empty statement ActiveRecord::Base.transaction do statements.each do |statement| connection.execute(statement) end end end
root()
click to toggle source
# File lib/conjoin/seeds.rb, line 4 def root File.expand_path(File.dirname(__FILE__)) end
run()
click to toggle source
# File lib/conjoin/seeds.rb, line 8 def run Dir["#{root}/seeds/**/*.rb"].each { |rb| require rb } end