{"action":"created","issue":{"url":"https://api.github.com/repos/rails/rails/issues/22154","labels_url":"https://api.github.com/repos/rails/rails/issues/22154/labels{/name}","comments_url":"https://api.github.com/repos/rails/rails/issues/22154/comments","events_url":"https://api.github.com/repos/rails/rails/issues/22154/events","html_url":"https://github.com/rails/rails/issues/22154","id":114538898,"number":22154,"title":"ActiveRecord::QueryCache and migration pending should disable if there is no database connection","user":{"login":"williscool","id":394931,"avatar_url":"https://avatars.githubusercontent.com/u/394931?v=3","gravatar_id":"","url":"https://api.github.com/users/williscool","html_url":"https://github.com/williscool","followers_url":"https://api.github.com/users/williscool/followers","following_url":"https://api.github.com/users/williscool/following{/other_user}","gists_url":"https://api.github.com/users/williscool/gists{/gist_id}","starred_url":"https://api.github.com/users/williscool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williscool/subscriptions","organizations_url":"https://api.github.com/users/williscool/orgs","repos_url":"https://api.github.com/users/williscool/repos","events_url":"https://api.github.com/users/williscool/events{/privacy}","received_events_url":"https://api.github.com/users/williscool/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-02T07:07:30Z","updated_at":"2015-11-02T07:23:02Z","closed_at":null,"body":"I had one hell of a time working on a status route for a rails 4.2.1 app \r\n\r\nchronicled here https://gitter.im/rails/rails?at=5636b7b53d7306ae0f297155\r\n\r\n\r\nbecause QueryCache was expecting the database to be up\r\n\r\nsolved with this rack middleware\r\n\r\n``` ruby\r\n# lib/custom_active_record_query_cache.rb\r\nclass CustomActiveRecordQueryCache < ActiveRecord::QueryCache\r\n  def call(env)\r\n    if ActiveRecord::Base.connected?\r\n      super(env)\r\n    else\r\n      # dont monkey with activerecord just do everything else\r\n      # https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/query_cache.rb#L36\r\n      # http://stackoverflow.com/questions/21293953/adding-a-custom-middleware-to-rails4\r\n      response = @app.call(env)\r\n      response[2] = Rack::BodyProxy.new(response[2]) do\r\n        # nuthin\r\n      end \r\n      response\r\n    end \r\n  end \r\nend\r\n```\r\n\r\nand then obviously\r\n\r\n\r\n``` ruby\r\n config.middleware.swap ActiveRecord::QueryCache , ::CustomActiveRecordQueryCache\r\n```\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/rails/rails/issues/comments/152941239","html_url":"https://github.com/rails/rails/issues/22154#issuecomment-152941239","issue_url":"https://api.github.com/repos/rails/rails/issues/22154","id":152941239,"user":{"login":"williscool","id":394931,"avatar_url":"https://avatars.githubusercontent.com/u/394931?v=3","gravatar_id":"","url":"https://api.github.com/users/williscool","html_url":"https://github.com/williscool","followers_url":"https://api.github.com/users/williscool/followers","following_url":"https://api.github.com/users/williscool/following{/other_user}","gists_url":"https://api.github.com/users/williscool/gists{/gist_id}","starred_url":"https://api.github.com/users/williscool/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/williscool/subscriptions","organizations_url":"https://api.github.com/users/williscool/orgs","repos_url":"https://api.github.com/users/williscool/repos","events_url":"https://api.github.com/users/williscool/events{/privacy}","received_events_url":"https://api.github.com/users/williscool/received_events","type":"User","site_admin":false},"created_at":"2015-11-02T07:23:02Z","updated_at":"2015-11-02T07:23:02Z","body":"This is also an issue with migration pending check as well https://github.com/rails/rails/blob/v4.2.1/activerecord/lib/active_record/migration.rb#L384\r\n"}}