gpt4 book ai didi

ruby-on-rails - 从本地 SQLite 到 Heroku 上的 Postgres 的 Rails 3.2

转载 作者:行者123 更新时间:2023-11-29 12:00:59 25 4
gpt4 key购买 nike

我在本地使用 sqlite 开发了一个应用程序,但现在想将其移至 Heroku,因此从现在开始我将使用 postgres。到目前为止,我不需要保留数据库,我只需要 Heroku 不要尝试安装 Sqlite,因为它会像这样爆炸:

Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.
/usr/local/bin/ruby extconf.rb
checking for sqlite3.h... no
sqlite3.h is missing. Try 'port install sqlite3 +universal'
or 'yum install sqlite-devel' and check your shared library search path (the
location where your sqlite3 shared library is located).
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers. Check the mkmf.log file for more
details. You may need configuration options.

我已经更改了我的 database.yml 文件,并将我的 Gemfile 中的 'gem' "sqlite3" 切换为 'gem' "pg",但 heroku 仍然很生气。还有什么需要更改,以便在我提交我的应用程序时它不会尝试安装 sqlite3?

最佳答案

将 Gemfile 更改为使用 gem 'pg' 后,您需要重新运行 bundle 命令。完成后,将 Gemfile 和 Gemfile.lock 提交到 git,然后将应用程序推送到 Heroku,它应该可以工作。

如果您不在本地运行 Postgres,那么您应该在 Gemfile 中将 gem 'pg' 添加到您的生产组中,否则当您在本地运行 bundle 时,它​​会在尝试编译 gem 时出现问题。您可以安全地将 gem 'sqlite' 移动到 Gemfile 中的开发组,以便在环境之间使用不同的数据库。 但是请注意,在部署时在本地运行同一个数据库是最安全的。

关于ruby-on-rails - 从本地 SQLite 到 Heroku 上的 Postgres 的 Rails 3.2,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10179128/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com