QA@IT

Heroku用「config.assets.initialize_on_precompile = false」設定の要不要について

4029 PV

Herokuにデプロイする際、config/application.rbに下記のAsset Pipeline用の設定をしていたのですが、この設定は現在の最新版(Rails3.2.9)でも必要でしょうか?

config.assets.initialize_on_precompile = false

現在の最新版では必要無いという話も聞くのですが、下記の通り設定なしの場合、Herokuへのpush時にエラーが発生する為、現在でも設定を記述する必要があるのかと思っています。

  • 設定なしの場合
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/blankslate-3.1.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems
       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_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `initialize'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `new'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:1208:in `connect'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:326:in `initialize'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `new'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/postgresql_adapter.rb:28:in `postgresql_connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/model_schema.rb:308:in `clear_cache!'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activerecord-3.2.9/lib/active_record/railtie.rb:97:in `block (2 levels) in <class:Railtie>'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:418:in `_run__805444968746887945__prepare__3155399887321274274__callbacks'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:405:in `__run_callback'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:385:in `_run_prepare_callbacks'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:81:in `run_callbacks'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/reloader.rb:74:in `prepare!'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/action_dispatch/middleware/reloader.rb:48:in `prepare!'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application/finisher.rb:47:in `block in <module:Finisher>'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `instance_exec'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:30:in `run'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:55:in `block in run_initializers'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `each'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/initializable.rb:54:in `run_initializers'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:136:in `initialize!'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/railtie/configurable.rb:30:in `method_missing'
       /tmp/build_3sa36arz9r3zt/config/environment.rb:5:in `<top (required)>'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:103:in `require_environment!'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/railties-3.2.9/lib/rails/application.rb:297:in `block (2 levels) in initialize_tasks'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/sprockets/assets.rake:93:in `block (2 levels) in <top (required)>'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/sprockets/assets.rake:60:in `block (3 levels) in <top (required)>'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/sprockets/assets.rake:23:in `invoke_or_reboot_rake_task'
       /tmp/build_3sa36arz9r3zt/vendor/bundle/ruby/1.9.1/gems/actionpack-3.2.9/lib/sprockets/assets.rake:29:in `block (2 levels) in <top (required)>'
       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
  • 設定した場合
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       /tmp/build_30l4jnplky0zo/vendor/bundle/ruby/1.9.1/gems/blankslate-3.1.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems
       /tmp/build_30l4jnplky0zo/vendor/bundle/ruby/1.9.1/gems/blankslate-3.1.2/lib/blankslate.rb:51: warning: undefining `object_id' may cause serious problems
       Asset precompilation completed (17.29s)

下記のRails Guides、Heroku Dev Centerにも記述がありますが、最新版 Rails3.2.9(もしくはRails4.0)での挙動や公式の見解のような情報があれば教えて頂ければと思います。

回答

ウォッチ

この質問への回答やコメントをメールでお知らせします。