現在railsチュートリアル5章までおわり、6章を進めようとしているものです。
railsをはじめて約一ヶ月ですが、かなりエラーが多発しており、苦戦中です。
今回、Gemfileに関するエラーが出たため、質問します。
実行したコード
$ rails generate model User name:string email:string
出たエラー
/usr/local/rvm/gems/ruby-2.4.1/gems/activerecord-5.1.4/lib/active_record/connection_adapters/connection_specification.rb:188:in `rescue in spec': Specified 'postgresql' for database adapter, but the gem is not loaded. Add `gem 'pg'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord). (Gem::LoadError) 以下、略
同じエラー文がのっていた、参考にしたサイト
・ Rails does not work with pg 1.0.0
・ “postgresql gem is not loaded” error deploying a Ruby on Rails application on Heroku
これを参考に
Gemfileにgem 'pg','0.20.0'やを追加したり、gem 'pg','~>0.18'を追加したりするのですが、うまくいきませんでした。
ちなみにGemfileは以下のとおりです。
source 'https://rubygems.org' gem 'rails', '5.1.4' gem 'puma', '3.9.1' gem 'sass-rails', '5.0.6' gem 'uglifier', '3.2.0' gem 'coffee-rails', '4.2.2' gem 'jquery-rails', '4.3.1' gem 'turbolinks', '5.0.1' gem 'jbuilder', '2.7.0' group :development, :test do gem 'sqlite3', '1.3.13' gem 'byebug', '9.0.6', platform: :mri end group :development do gem 'web-console', '3.5.1' gem 'listen', '3.1.5' gem 'spring', '2.0.2' gem 'spring-watcher-listen', '2.0.1' end group :test do gem 'rails-controller-testing', '1.0.2' gem 'minitest-reporters', '1.1.14' gem 'guard', '2.13.0' gem 'guard-minitest', '2.4.4' end group :production do gem 'pg', '0.20.0' end # Windows環境ではtzinfo-dataというgemを含める必要があります gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] source 'https://rubygems.org' gem 'rails', '5.1.4' gem 'bootstrap-sass', '3.3.7'
ご回答いただけると幸いです。
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/08/18 09:41