Kie*_*sen 25 assets ruby-on-rails heroku ruby-on-rails-3
我正在尝试为我的应用程序预编译资产以部署到Heroku,但必须遵循错误.
运行时:
RAILS_ENV=production bundle exec rake assets:precompile
Run Code Online (Sandbox Code Playgroud)
错误:
/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets
rake aborted!
Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (pg is not part of the bundle. Add it to Gemfile.)
Run Code Online (Sandbox Code Playgroud)
因为我在开发SQLite和生产Postgresql时使用以下Gemfile
gem "rails", "~> 3.1.0"
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem 'sass-rails', "~> 3.1.0"
group :assets do
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier'
gem 'compass', '~> 0.12.alpha.0'
gem 'html5-boilerplate'
end
Run Code Online (Sandbox Code Playgroud)
我尝试了很多,但不能让这个工作.
我不知道这是否重要,但我的database.yml看起来像:
production:
adapter: postgresql
host: localhost
database: db
encoding: unicode
username: user
password: ''
Run Code Online (Sandbox Code Playgroud)
mra*_*ruz 54
旧的问题,但接受的答案并没有真正回答这个问题 - 我只是在搜索中找到了这个,所以我猜它是相关的.
错误的原因在于gem 'pg'
生产宝石组.
当您运行rake assets:precompile
生产环境时,访问.因此它正在尝试加载生产环境,但您没有安装所有依赖项.
跑步RAILS_ENV=production bundle exec rails server
可能会给你一个类似的错误.
我可以想到两种不同的解决方案
1)查看.bundle/config
您的应用根目录中是否有文件.如果您这样做,请检查它是否WITHOUT :production
相似.删除该行或整个.bundle
目录,然后bundle
再次运行.
2)in Gemfile
gem :development, :production do
gem 'pg'
end
Run Code Online (Sandbox Code Playgroud)
同时删除:production
组再次
运行bundle
抱歉带来旧东西......
归档时间: |
|
查看次数: |
48657 次 |
最近记录: |