Skip to content

Instantly share code, notes, and snippets.

@kermit-klein
Created July 30, 2020 17:53
Show Gist options
  • Save kermit-klein/a8e0cd73333955f937eca5efe3736b9d to your computer and use it in GitHub Desktop.
Save kermit-klein/a8e0cd73333955f937eca5efe3736b9d to your computer and use it in GitHub Desktop.
cypress_controller
class Test::DatabasesController < ApplicationController
def reset_database
tables = ActiveRecord::Base.connection.tables
tables.delete 'schema.migrations'
tables.each do |table|
ActiveRecord::Base.connection.execute("DELETE FROM #{table}")
ActiveRecord::Base.connection.execute("DELETE FROM sqlite_sequence where name='#{table}'")
end
Rails.application.load_seed if params['seed'] == true
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment