Railsで新しいアプリを作ったらActiveRecord::ConnectionNotEstablishedが出てきた
こんにちは!モリタケンタロウです!
今回はRailsでアプリを新規作成して動かしてみたら、「ActiveRecord::ConnectionNotEstablished」というエラーが出てきたので、それを解決する方法について紹介します。
開発環境
- ruby 2.6.3p62
- Rails 5.0.0
エラー内容
rails server
コマンドでアプリを動かすと、画面にはこんなエラーが出てきます。
ActiveRecord::ConnectionNotEstablished
No connection pool with id primary found
なにこれ!?分からん…
ということでググると、RailsのORM機能であるActiveRecordが、sqlite3
の新しいバージョンに対応してないことが原因らしい。(参考:ActiveRecord::ConnectionNotEstablished No connection pool)
対処内容
ということで、Railsがインストールしているパッケージを管理しているGemfileを編集します。
gem 'sqlite3', '~> 1.3.6'
Gemfileを編集したら、bundle install
コマンドでインストールパッケージを更新します。
そしてrails server
コマンドでアプリを起動すると…
見事、アプリが正常に起動しました。めでたしめでたし!
ということで一件落着(^^)
それでは~
Author And Source
この問題について(Railsで新しいアプリを作ったらActiveRecord::ConnectionNotEstablishedが出てきた), 我々は、より多くの情報をここで見つけました https://qiita.com/MORITAKENTARO/items/e8d5306a07715db6c4f2著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .