Ruby on rails 4 RAILS-如何自动重新连接到pg db

Ruby on rails 4 RAILS-如何自动重新连接到pg db,ruby-on-rails-4,pg,Ruby On Rails 4,Pg,我正在用Postgres db运行我的rails 4应用程序,有时我的db连接会丢失,出现以下异常 PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly This probably means the server terminated abnormally before or while processing the request. 在我重新启动应用程序后

我正在用Postgres db运行我的rails 4应用程序,有时我的db连接会丢失,出现以下异常

 PG::ConnectionBad: PQconsumeInput() server closed the connection unexpectedly
        This probably means the server terminated abnormally
        before or while processing the request.
在我重新启动应用程序后,连接正在正常恢复,他们是否仍要自动重新连接到活动记录连接