Skip to content

Instantly share code, notes, and snippets.

View nononoy's full-sized avatar

Slava Gruzdov nononoy

View GitHub Profile
module BeforeRender
extend ActiveSupport::Concern
included do
define_callbacks :render
end
def render(*args, &block)
run_callbacks(:render) do
super
@nononoy
nononoy / seeds.rb
Created November 11, 2015 08:25 — forked from seyhunak/seeds.rb
Rails - Import SQL file as seed
unless Rails.env.production?
connection = ActiveRecord::Base.connection
connection.tables.each do |table|
connection.execute("TRUNCATE #{table}") unless table == "schema_migrations"
end
sql = File.read('db/import.sql')
statements = sql.split(/;$/)
statements.pop