Skip to content

Instantly share code, notes, and snippets.

@thilo
Created January 24, 2011 14:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thilo/793294 to your computer and use it in GitHub Desktop.
Save thilo/793294 to your computer and use it in GitHub Desktop.
implementation of dev interface
## steps
Before do
Client::Config.backend_uri.values.each do |uri|
begin
HTTParty.post("#{uri}dev/purge_db", :body => {})
rescue Errno::ECONNREFUSED
p "could not reach #{uri}"
end
end
end
## controller
if Rails.env.test?
require 'database_cleaner'
class DevController < ActionController::Base
def purge_db
DatabaseCleaner.strategy = :truncation
DatabaseCleaner.clean
render :nothing => true
end
end
end
## routes
match '/dev(/:action)', :controller => 'dev', :via => :post if Rails.env.test?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment