嘿我正在尝试在heroku上部署rails应用程序,当我运行git push heroku master时,我收到以下错误消息

时间:2018-03-03 06:46:42

标签: ruby-on-rails heroku

    remote:        
    Gem::LoadError: 
    **strong text**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文件中加载了这个:

    source 'https://rubygems.org'

    git_source(:github) do |repo_name|
   repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?
    ("/") "https://github.com/#{repo_name}.git"
    end

宝石:         gem' jquery-rails'         gem' active_model_serializers',' 0.10.6'         #Bundle edge Rails代替:gem' rails',github:' rails / rails'         宝石' rails','〜> 5.1.3'         #使用sqlite3作为Active Record的数据库         #使用Puma作为应用服务器         宝石' puma','〜> 3.7'         #将SCSS用于样式表         宝石' sass-rails','〜> 5.0'         #使用Uglifier作为JavaScript资源的压缩器         gem' uglifier','> = 1.3.0'         #有关更多支持,请参阅https://github.com/rails/execjs#readme         运行时间         #gem' therubyracer',platforms :: ruby​​

    # Use CoffeeScript for .coffee assets and views
    gem 'coffee-rails', '~> 4.2'
    # Turbolinks makes navigating your web application faster. Read 
    more: 
    https://github.com/turbolinks/turbolinks
    gem 'turbolinks', '~> 5'
    # Build JSON APIs with ease. Read more: 
    https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 2.5'
    # Use Redis adapter to run Action Cable in production
    # gem 'redis', '~> 3.0'
    # Use ActiveModel has_secure_password
    # gem 'bcrypt', '~> 3.1.7'
    gem 'nokogiri'

    # Use Capistrano for deployment
    # gem 'capistrano-rails', group: :development

    group :development, :test do
    # Call 'byebug' anywhere in the code to stop execution and get a 
    debugger console
    gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
    # Adds support for Capybara system testing and selenium driver
    gem 'sqlite3'
    gem 'capybara', '~> 2.13'
    gem 'selenium-webdriver'
    end

    group :production do
    gem 'pg'
    end

    group :development do
     # Access an IRB console on exception pages or by using <%= console 
     %> anywhere in the code.
    gem 'web-console', '>= 3.3.0'
    gem 'listen', '>= 3.0.5', '< 3.2'
    # Spring speeds up development by keeping your application running 
    in the background. Read more: https://github.com/rails/spring
    gem 'spring'
    gem 'spring-watcher-listen', '~> 2.0.0'
    end

    # Windows does not include zoneinfo files, so bundle the tzinfo-
    data gem
    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
    gem 'devise'
    gem 'omniauth-facebook'
    gem 'flash'
    gem 'pry'

^^宝石文件的结尾

我运行了bundle install -without production。这不起作用。不知道我在哪里错了。

2 个答案:

答案 0 :(得分:0)

在gemfile中指定pg的版本。我曾经收到同样的错误,这条线对我有效。

gem 'pg', '~> 0.18' 

而不只是gem&#39; pg&#39;

答案 1 :(得分:0)

移动线

gem 'pg'

group :production

所以gem将安装在任何类型的环境中