编辑:我是一个新的 ruby on rails 学生。
在我的 Git Push Heroku Master 之后,我遇到了 Heroku 的问题。这是最新和最好的,中止 rake Assets :预编译。
-----> Preparing app for Rails asset pipeline
Running: rake assets:precompile
rake aborted!
could not connect to server: Connection refused
Is the server running on host "127.0.0.1" and accepting
TCP/IP connections on port 5432?
Tasks: TOP => environment
(See full trace by running task with --trace)
Precompiling assets failed, enabling runtime asset compilation
Injecting rails31_enable_runtime_asset_compilation
Please see this article for troubleshooting help:
http://devcenter.heroku.com/articles/rails31_heroku_cedar#troubleshooting
下面是我的 Gemfile 的内容:
gem 'rails', '3.2.8'
gem 'bootstrap-sass', '2.1'
gem 'pg'
group :development, :test do
gem 'rspec-rails'
gem 'guard-rspec'
gem 'guard-spork'
gem 'spork'
gem 'annotate'
gem 'database_cleaner'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
end
platforms :jruby do
gem 'trinidad'
gem 'jruby-openssl'
end
gem 'jquery-rails'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug'
# Bundle the extra gems:
gem 'RedCloth', '~> 4.2.9', :require => 'redcloth'
gem 'ruby-openid', :require => 'openid'
gem 'rack-openid', :require => 'rack/openid'
gem 'aaronh-chronic', :require => 'chronic' # Fixes for 1.9.2
gem 'coderay'
gem 'lesstile'
gem 'formtastic'
gem 'will_paginate', '~> 3.0.2'
gem 'exception_notification', '~> 2.5.2'
gem 'open_id_authentication'
# Bundle gems for the local environment. Make sure to
# put test-only gems in this group so their generators
# and rake tasks are available in development mode:
group :test do
gem 'database_cleaner'
gem 'cucumber-rails', :require => false
gem 'cucumber-websteps', :require => false
gem 'factory_girl'
gem 'rspec'
gem 'nokogiri', '~> 1.5.0'
gem 'webrat'
end
可能是什么问题?
更新:我使用 --trace 运行了 rake 命令,它警告我失败,因为生产数据库不存在。我创建了数据库,然后再次运行 --trace,这就是我目前被抛出的:
Command failed with status (1): [/usr/local/Cellar/ruby/1.9.3-p286/bin/ruby...]
最佳答案
见 Rails 3.1+ Asset Pipeline on Heroku Cedar文章。故障排除部分涵盖了这种确切的场景。
简而言之,您的 Heroku 应用程序在构建(包括 Assets 编译)和运行(您的应用程序可用的地方)之间有很强的分离。这与12-factor app principles一致,但这意味着您的应用程序在构建阶段无法访问任何配置的资源——包括数据库——这意味着在 Assets 预编译期间 ActiveRecord 不可用。
您可以在 config/application.rb
中告诉 Rails 在 Assets 编译期间不要引导您的应用程序:
config.assets.initialize_on_precompile = false
故障排除部分还建议:
If rake assets:precompile is still not working, you can debug this locally by configuring a nonexistent database in your local
config/database.yml
and attempting to runrake assets:precompile
. Ideally you should be able to run this command without connecting to the database.
关于ruby-on-rails - 推送到 heroku 时出错 - 中止我的佣金 Assets :precompile,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13712012/