我会尽力解释我的问题。
我有一个包含大约 50,000 条记录的 SQLite3 数据库文件,我在我的应用程序中编译并使用了这些文件。该数据库是只读的,仅用于查询和提取数据。我在 Rails 中为它创建了一个模型,它看起来像这样。
class Locations < ActiveRecord::Base
establish_connection(
:adapter => 'sqlite3',
:database => 'db/locs.sqlite3'
)
set_table_name "Locations"
end
在开发端一切正常,但当我部署到 Heroku 时却失败了。我假设问题是 Heroku 在 Postrgres 上运行,但我需要这个数据库与主要生产数据库分开,我不需要花哨的东西。我所需要的只是应用程序从该文件中查询一些记录。
有解决办法吗?谢谢
最佳答案
可以按照此 git 存储库中的步骤启用 SQLite3 只读。
https://github.com/yotsumoto/heroku-buildpack-ruby-with-sqlite3
运行后:
$ heroku config:set BUILDPACK_URL=https://github.com/yotsumoto/heroku-buildpack-ruby-with-sqlite3
我能够 git push heroku master
并且 gem 'sqlite3'
仍在 Gemfile 中。
关于ruby-on-rails - Heroku 中的静态只读 SQLite3 数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16825367/