【问题标题】:Deploying App to Heroku将应用程序部署到 Heroku
【发布时间】:2012-07-16 14:48:03
【问题描述】:

当我想将我的应用程序部署到 heroku(使用 git push heroku master)时,它给了我一个错误并告诉我安装 sqlite3 -v '1.3.6'。因此,在成功安装该 gem 后,我尝试再次将其部署到 heroku,但它仍然给我同样的错误!但是,我已经安装了它。现在我什至无法在本地运行我的 rails 项目(rails 服务器)。我可以知道这可能是什么原因吗?

这是我在 database.yml 文件中的内容:

# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
development:
  adapter: sqlite3
  database: db/development.sqlite3
  pool: 5
  timeout: 5000

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  adapter: sqlite3
  database: db/test.sqlite3
  pool: 5
  timeout: 5000

production:
  adapter: sqlite3
  database: db/production.sqlite3
  pool: 5
  timeout: 5000

【问题讨论】:

  • 您是否进行了捆绑安装?你能发布你的 database.yml 文件吗
  • yeap.. 现在我收到错误消息:“找不到 RubyGem Bundler……”这很奇怪,因为我已经使用 Rails 一个月了,但我还没有遇到什么问题! :( 无论如何,我已经在 qn 中发布了 database.yml 文件
  • 另外,heroku 使用 postgres,所以在你的 gemfile 中将 sqlite gem 放在组中:development do

标签: ruby-on-rails git deployment heroku


【解决方案1】:

让你的 gemfile 看起来像这样

      group :production do
         gem 'pg'
      end
      group :development, :test do
         gem 'sqlite3-ruby', :require => 'sqlite3'
      end

【讨论】:

    【解决方案2】:

    Heroku 不适用于 SQLite3

    打开您的 Gemfile 并替换该行:

    gem 'sqlite3'
    

    group :production do
      gem 'pg'
    end
    
    group :development, :test do
      gem 'sqlite3'
    end
    

    我还建议你阅读 heroku 说明:https://devcenter.heroku.com/articles/rails3

    【讨论】:

    • 成功了!谢谢!虽然现在我又遇到了一个关于“我们很抱歉,但出了点问题”的问题哈哈哈!这是另一个问题,但非常感谢您解决了这个问题! :D
    猜你喜欢
    • 2012-11-22
    • 2015-12-25
    • 2015-02-27
    • 2018-04-06
    • 2016-11-16
    • 2018-01-25
    • 1970-01-01
    相关资源
    最近更新 更多