Active Record Rack Status
Lightweight Rack Middleware for testing active record connections
gem install rack-active_record_status
require 'rack/active_record_status' use Rack::ActiveRecordStatus
Or, if you are using Bundler, just add this to your Gemfile:
gem 'rack-active_record_status', :require => 'rack/active_record_status'
To use Rack::ActiveRecordStatus in your Rails application, add the following line to your application config file (config/application.rb for Rails 3, config/environment.rb for Rails 2):
config.middleware.use Rack::ActiveRecordStatus # In older Rails, like 2.3.4, defer loading using a string: config.middleware.use "Rack::ActiveRecordStatus"
Test your ActiveRecord connection by hitting
Anything other than a 200 OK HTTP response code is an error.
Use the `:path` option to configure what patht eh middleware responds to. Use the `:response` option to change the default response.
config.middleware.use Rack::ActiveRecordStatus, :path => '/custom_path' # Respond on /custom_path config.middleware.use Rack::ActiveRecordStatus, :response => "I'm alive!" # A different response
For rails apps, a useful response is the REVISION file created by deployment tools (like Capistrano).
revision = Rails.root.join('REVISION').read rescue $!.to_s config.middleware.use Rack::ActiveRecordStatus, :response => revision
Work on rack-active_record_status is sponsored by Medidata Solutions
(The MIT License)
Copyright © 2011 Aaron Suggs
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.