【问题标题】:hey I am trying to deploy a rails app on heroku, and i get the follow error message when i run git push heroku master嘿,我正在尝试在 heroku 上部署一个 rails 应用程序,当我运行 git push heroku master 时收到以下错误消息
【发布时间】:2018-03-03 06:46:41
【问题描述】:
    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

宝石: 宝石'jquery-rails' 宝石'active_model_serializers','0.10.6' # 捆绑边缘 Rails:gem 'rails', github: 'rails/rails' gem 'rails', '~> 5.1.3' # 使用 sqlite3 作为 Active Record 的数据库 # 使用 Puma 作为应用服务器 宝石'美洲狮','〜> 3.7' # 使用 SCSS 作为样式表 gem 'sass-rails', '~> 5.0' # 使用 Uglifier 作为 JavaScript 资源的压缩器 gem 'uglifier', '>= 1.3.0' # 更多支持见https://github.com/rails/execjs#readme 运行时 # gem 'therubyracer', 平台: :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'

^^Gem 文件结束

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

【问题讨论】:

标签: ruby-on-rails heroku


【解决方案1】:

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

gem 'pg', '~> 0.18' 

而不仅仅是 gem 'pg'

【讨论】:

    【解决方案2】:

    移动线

    gem 'pg'
    

    外面 group :production

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-27
      • 2016-02-19
      • 2016-07-11
      • 1970-01-01
      • 2019-10-14
      • 2019-02-08
      • 1970-01-01
      • 2022-07-15
      相关资源
      最近更新 更多