【发布时间】:2015-04-16 09:15:46
【问题描述】:
我正在尝试运行 $ rake assets:precompile RAILS_ENV=production 以:1) 缩小我的资产(遵循此答案:How do I minify CSS in Rails 4?)和 2) 在我的 JS 中使用生产级变量(即,我的 JS 有 ENV['variable']当我运行常规的rake assets:precompile 然后推送到 Heroku 时,代码会使用 ENV['variable'] 的开发版本而不是生产版本运行。
但是,我遇到了一个错误:
rake aborted!
Gem::LoadError: 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).
错误是响应我正在编译的 JS 文件中的这一行:
var items_to_be_added = [{
id: '<%= ItemName.where(name:"Jacket").first.id %>',
name: "Jacket",
number: 1
}
但奇怪的是我运行了heroku run gem list 并且已经安装了pg 0.15.1。
非常感谢任何帮助!
【问题讨论】:
-
你的 database.yml 文件是什么样的?
-
@evanbikes 很有趣,我正在使用 SQLite,它看起来像......但我尝试删除它,仍然有同样的问题
标签: sql ruby-on-rails ruby-on-rails-4 heroku asset-pipeline