Skip to content

Instantly share code, notes, and snippets.

@lmiller1990
Created September 28, 2018 04:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lmiller1990/6785c2ebe503c113f28f78a086e9ad59 to your computer and use it in GitHub Desktop.
Save lmiller1990/6785c2ebe503c113f28f78a086e9ad59 to your computer and use it in GitHub Desktop.
module Test
class DatabasesController < ApplicationController
skip_before_action :verify_authenticity_token
def clean_database
tables = ActiveRecord::Base.connection.tables
tables.delete 'schema.migrations'
tables.each { |t| ActiveRecord::Base.connection.execute("TRUNCATE #{t} CASCADE") }
Rails.application.load_seed unless ['false', false].include?(params['database']['should_seed'])
render plain: 'Truncated and seeded database'
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment