Heroku预编译资产在Rail 4应用程序上失败 [英] Heroku precompile assets failed on Rail 4 app

查看:100
本文介绍了Heroku预编译资产在Rail 4应用程序上失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设置了

  config.assets.initialize_on_precompile = false 


。通过运行本地成功预编译资源

  RAILS_ENV =生产捆绑包exec rake资产:预编译

虽然manifest-fingerprint.json(Rails 4.0生成manifest.json而不是manifest.yml)在推送到Heroku时未被检测到,Heroku尝试再次运行预编译。然后我得到了这样的错误:

 运行:rake assets:预编译
rake中止!
无法连接到服务器:连接被拒绝
服务器是否在主机127.0.0.1上运行并接受端口5432上的
TCP / IP连接?
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:771:in`initialize'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / activerecord-4.0.0.beta1 / lib / active_record / connection_adapters / postgresql_adapter.rb:771:在`new'
/ tmp / build_2ospgf61r6sch / vendor /bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:771:in`connect'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / activerecord-4.0.0.beta1 / lib / active_record / connection_adapters / postgresql_adapter.rb:493:in`initialize'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems /activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in`new'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0。 0.beta1 / LIB / active_record / connection_adapters / postgresql_adapter .rb:41:在`postgresql_connection'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb: 446:在`new_connection'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:456:in `checkout_new_connection'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:427:in`acquire_connection'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in`block in checkout'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in`checkout'
的/ tmp / build_2ospgf61r6s ch / vendor / bundle / ruby​​ / 2.0.0 / gems / activerecord-4.0.0.beta1 / lib / active_record / connection_adapters / abstract / connection_pool.rb:273:在`block in connection'
/ tmp / build_2ospgf61r6sch /vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:272:in`connection'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / activerecord-4.0.0.beta1 / lib / active_record / connection_adapters / abstract / connection_pool.rb:552:in'retrieve_connection'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby /2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_handling.rb:79:in`retrieve_connection'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/ activerecord-4.0.0.beta1 / lib / active_record / connection_handling.rb:53:在`connection'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1 /lib/active_record/model_schema.rb:208:in`列'
/ t mp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / activerecord-4.0.0.beta1 / lib / active_record / model_schema.rb:242:在`column_defaults'
/ tmp / build_2ospgf61r6sch / vendor / bundle /ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/locking/optimistic.rb:169:in`column_defaults'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0。 0 / gems / activerecord-4.0.0.beta1 / lib / active_record / core.rb:164:在`initialize'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0 .0.beta1 / lib / active_record / inheritance.rb:24:在`new'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/ active_record / inheritance.rb:24:`new'
/tmp/build_2ospgf61r6sch/lib/student_module.rb:11:in`acts_as_student'
/tmp/build_2ospgf61r6sch/app/models/applicant.rb: 4:在< class:Applicant>'
/tmp/build_2ospgf61r6sch/app/models/applicant.rb:3:in`< top(required)>'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in`require'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / activesupport-4.0.0.beta1 / lib / active_support / dependencies.rb:228:在`block in require'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0 .0 / gems / activesupport-4.0.0.beta1 / lib / active_support / dependencies.rb:213:in`load_dependency'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport- 4.0.0.beta1 / lib / active_support / dependencies.rb:228:在'require'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib /active_support/dependencies.rb:329:in`require_or_load'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb: 288:在`depend_on'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active _support / dependencies.rb:206:在'require_dependency'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:464 :在'eager_load!'的块(2级)'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:463 :在`each'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:463:in`block in eager_load! '
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:461:in`each'
/ tmp /build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:461:in`eager_load!'
/ tmp / build_2ospgf61r6sch / vendor / bundle /ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:346:in`eager_load!'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0 /gems/railties-4.0.0.beta1/lib/rails/application/finisher.rb:56:in`each'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application/finisher.rb:56:in`block in< module:Finisher>'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/initializable.rb:30:in`instance_exec'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / railties-4.0.0.beta1 / lib / rails / initializable.rb:30:在`run'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0 .0 / gems / railties-4.0.0.beta1 / lib / rails / initializable.rb:55:在`block in run_initializers'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/ railties-4.0.0.beta1 / lib / rails / initializable.rb:54:在`run_initializers'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1 /lib/rails/application.rb:213:in`initialize!'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/railtie `method_missing /configurable.rb:30:`
/tmp/build_2ospgf61r6sch/config/environment.rb:5:in`< top(required)>'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport -4.0.0.beta1 / lib / active_support / dependencies.rb:228:在'require'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/ lib / active_support / dependencies.rb:228:在`block in require'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies .rb:213:在`load_dependency'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in`需要'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:187:in`require_environment!'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:247:in`block in run_tasks_blocks'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in`call'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby / 2.0.0 / gems / rake-10.0.4 / lib / rake / task.rb:246:在`block in execute'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems /rake-10.0.4/lib/rake/task.rb:241:in`each'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/ rake / task.rb:241:在`execute'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in`invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:170:in`invoke'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby / 2.0.0 / gems / sprockets-rails-2.0.0.rc4 / lib / sprockets / rails / task.rb:16:在'block(2 levels)in define'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in`call'
/ tmp / build_2ospgf61r6sch / vendor / bundle /ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in`block in execute'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/ gems / rake-10.0.4 / lib / rake / task.rb:241:在`each'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib /rake/task.rb:241:in`execute'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:184: in`block in invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in`invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:205:in`block in invoke_prerequisites'
/ tmp / build_2ospgf61r6sch / vendor /bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:203:in`each'
/ tmp / build _2spgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / rake-10.0.4 / lib / rake / task.rb:203:在`invoke_prerequisites'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0 .0 / gems / rake-10.0.4 / lib / rake / task.rb:183:在`block in invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake- 10.0.4 / lib / rake / task.rb:177:在`invoke_with_call_chain'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task .rb:170:in`invoke'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:143:in`invoke_task'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in'block(2 levels)in top_level'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in`each'
/ tmp / build_2ospgf61r6sch / vendor / bundle /ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in`block in to p_level'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:110:in`run_with_threads'
/ tmp / build_2ospgf61r6sch / vendor / bundle / ruby​​ / 2.0.0 / gems / rake-10.0.4 / lib / rake / application.rb:95:in'top_level'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0 .0 / gems / rake-10.0.4 / lib / rake / application.rb:73:在`block in run'中
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake- 10.0.4 / lib / rake / application.rb:160:在`standard_exception_handling'
/tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application .rb:70:在`run'中

看起来错误是由于lib /在config / initializers / student_init.rb中需要student_module.rb:

 #lib / student_module.rb,到这一行:
user_attributes = User.new.abttributes.keys
#config / initializers / student_init.rb
require student_module'
ActiveRecord :: Base.extend Student

错误可能是因为Heroku初始化应用程序,其中包括连接到数据库。但我不应该看到像

  rake中止的消息! 
无法连接到服务器:连接被拒绝
服务器是否在主机127.0.0.1上运行并接受端口5432上的
TCP / IP连接?

因为我将config.assets.initialize_on_precompile设置为false,并且在本地预编译资产。



解决此问题的任何建议?谢谢!

实验室功能在Heroku的user-env-compile上,让编译时应用程序可以访问环境变量。

  heroku labs:enable user-env-compile -a myapp 

https://devcenter.heroku.com/articles/labs-user-env-compile


I set

config.assets.initialize_on_precompile = false

in the application.rb. Assets were precompiled successfully locally by run

RAILS_ENV=production bundle exec rake assets:precompile

While the manifest-fingerprint.json(Rails 4.0 generates manifest.json instead of manifest.yml) was not detected when pushed to Heroku and Heroku tried to run precompile again. Then I got the error as:

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?
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:771:in `initialize'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:771:in `new'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:771:in `connect'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:493:in `initialize'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `new'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/postgresql_adapter.rb:41:in `postgresql_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:446:in `new_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:456:in `checkout_new_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:427:in `acquire_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:364:in `block in checkout'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:363:in `checkout'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:273:in `block in connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:272:in `connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_adapters/abstract/connection_pool.rb:552:in `retrieve_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_handling.rb:79:in `retrieve_connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/connection_handling.rb:53:in `connection'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/model_schema.rb:208:in `columns'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/model_schema.rb:242:in `column_defaults'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/locking/optimistic.rb:169:in `column_defaults'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/core.rb:164:in `initialize'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/inheritance.rb:24:in `new'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activerecord-4.0.0.beta1/lib/active_record/inheritance.rb:24:in `new'
       /tmp/build_2ospgf61r6sch/lib/student_module.rb:11:in `acts_as_student'
       /tmp/build_2ospgf61r6sch/app/models/applicant.rb:4:in `<class:Applicant>'
       /tmp/build_2ospgf61r6sch/app/models/applicant.rb:3:in `<top (required)>'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `block in require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:213:in `load_dependency'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:329:in `require_or_load'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:288:in `depend_on'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:206:in `require_dependency'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:464:in `block (2 levels) in eager_load!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:463:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:463:in `block in eager_load!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:461:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:461:in `eager_load!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/engine.rb:346:in `eager_load!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application/finisher.rb:56:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application/finisher.rb:56:in `block in <module:Finisher>'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/initializable.rb:30:in `run'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:213:in `initialize!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_2ospgf61r6sch/config/environment.rb:5:in `<top (required)>'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `block in require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:213:in `load_dependency'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.0.beta1/lib/active_support/dependencies.rb:228:in `require'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:187:in `require_environment!'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/railties-4.0.0.beta1/lib/rails/application.rb:247:in `block in run_tasks_blocks'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.0.rc4/lib/sprockets/rails/task.rb:16:in `block (2 levels) in define'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `call'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:246:in `block in execute'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:241:in `execute'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:184:in `block in invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:205:in `block in invoke_prerequisites'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:203:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:203:in `invoke_prerequisites'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:183:in `block in invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:177:in `invoke_with_call_chain'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/task.rb:170:in `invoke'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:143:in `invoke_task'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `block (2 levels) in top_level'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `each'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:101:in `block in top_level'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:110:in `run_with_threads'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:95:in `top_level'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:73:in `block in run'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:160:in `standard_exception_handling'
       /tmp/build_2ospgf61r6sch/vendor/bundle/ruby/2.0.0/gems/rake-10.0.4/lib/rake/application.rb:70:in `run'

Seems the error was due to the file in the lib/student_module.rb, which was required in config/initializers/student_init.rb:

#lib/student_module.rb, the error pointed to this line:
user_attributes = User.new.abttributes.keys
#config/initializers/student_init.rb
require 'student_module'
ActiveRecord::Base.extend Student

The error could be because Heroku initializes the app, which includes connection to the database. But I was not supposed to see the messages like

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?

because I set config.assets.initialize_on_precompile false and also precompile the assets locally.

Any suggestions to solve this?Thanks!

解决方案

You'll need to enable a labs feature on Heroku user-env-compile which gives the app access to the environment variables at compile time.

heroku labs:enable user-env-compile -a myapp

Read more about it at https://devcenter.heroku.com/articles/labs-user-env-compile

这篇关于Heroku预编译资产在Rail 4应用程序上失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆