2013-11-04 90 views
0

我想第一次將我的Rails應用程序部署到heroku上。我在Windows 8上使用Rails 3.2.11和ruby 1.9.3。我一直在尋找很長時間來回答問題,但一直沒有成功。我一直沿着heroku's tutorial開始,直到它告訴你推。第一次無法將rails應用程序部署到heroku;忽略manifest.yml文件

git push heroku master 

這給了我下面的錯誤:

-----> Writing config/database.yml to read from DATABASE_URL 
-----> Preparing app for Rails asset pipeline 
Running: rake assets:precompile 
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! 
Support for these plugins will be removed in Rails 4.0. Move them out and bundle 
them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/ 
initializers/myplugin.rb. See the release notes for more on this: http://weblog. 
rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from at   
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/Rakefile:7) 
DEPRECATION WARNING: You have Rails 2.3-style plugins in vendor/plugins! 
Support for these plugins will be removed in Rails 4.0. Move them out and bundle 
them in your Gemfile, or fold them in to your app as lib/myplugin/* and config/ 
initializers/myplugin.rb. See the release notes for more on this: http://weblog. 
rubyonrails.org/2012/1/4/rails-3-2-0-rc2-has-been-released. (called from at  
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/Rakefile:7) 
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_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:1208:in initialize' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:1208:innew' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:1208:in connect' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:326:ininitialize' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:28:in new' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/postgresql_adapte 
r.rb:28:inpostgresql_connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:315:in new_connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:325:incheckout_new_connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:247:in block (2 levels) in checkout' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:242:inloop' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:242:in block in checkout' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:239:incheckout' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:102:in block in connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:101:inconnection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_pool.rb:410:in retrieve_connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_specification.rb:171:inretrieve_connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/connection_adapters/abstract/connecti 
on_specification.rb:145:in connection' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/model_schema.rb:308:inclear_cache!' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activerecord-3.2.11/lib/active_record/railtie.rb:97:in block (2 levels) in 
<class:Railtie>' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/callbacks.rb:418:in_run__35780770 
63533031320__prepare__2058969196489290367__callbacks' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/callbacks.rb:405:in __run_callback 
' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/callbacks.rb:385:in_run_prepare_c 
allbacks' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/callbacks.rb:81:in run_callbacks' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:74:inprepare 
!' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/action_dispatch/middleware/reloader.rb:48:in prepare 
!' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/application/finisher.rb:47:inblock in ' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/initializable.rb:30:in instance_exec' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/initializable.rb:30:inrun' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/initializable.rb:55:in block in run_initializers 
' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/initializable.rb:54:ineach' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/initializable.rb:54:in run_initializers' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/application.rb:136:ininitialize!' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/railtie/configurable.rb:30:in method_missing' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/config/environment.rb:5:i 
n' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in require' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:inblock in re 
quire' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/v 
gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in load_depend 
ency' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:inrequire' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/application.rb:103:in require_environment!' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/railties-3.2.11/lib/rails/application.rb:297:inblock (2 levels) in initia 
lize_tasks' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/sprockets/assets.rake:93:in block (2 levels) in <top 
(required)>' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/sprockets/assets.rake:60:inblock (3 levels) in ' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/sprockets/assets.rake:23:in invoke_or_reboot_rake_ta 
sk' 
/tmp/build_7255e9b5-d3d1-4b02-adaf-b98a0f6b4528/vendor/bundle/ruby/2.0.0/ 
gems/actionpack-3.2.11/lib/sprockets/assets.rake:29:inblock (2 levels) in ' 
Tasks: TOP => environment 
(See full trace by running task with --trace) 
! 
! Precompiling assets failed. 
! 
! Push rejected, failed to compile Ruby app 
To [email protected]:myapp.git 
!  [remote rejected] master -> master (pre-receive hook declined) 
error: failed to push some refs to '[email protected]:myapp.git' 

我也試着預編譯資產產生使用:

bundle exec rake assets:precompile 

這在我的公共/租入資產價值產生manifest.yml文件目錄。我已經提交了該文件。所以,根據我見過的教程,它不應該試圖預編譯這些文件。爲什麼忽略我的manifest.yml文件?

請讓我知道我能做些什麼。我想不明白。

謝謝!

+0

它實際上看起來像DATABASE_URL設置不正確,因爲錯誤是在數據庫連接。運行'heroku config'時DATABASE_URL顯示的內容。你有沒有建立一個數據庫加載項? –

+0

感謝您的回覆。我運行了heroku配置,並且myapp沒有配置變量。我假設這是因爲我以前從未部署過任何服務器。 – user2951507

+0

@PeterGoldstein除了在入門教程中採取的步驟之外,我還沒有對數據庫做更多的事情。我應該採取額外的步驟嗎? – user2951507

回答

1

好的,我很近。拋出Rails 3.2.x - 我現在使用4.0.x。

從Heroku的文檔:

雖然預編譯的資產,在Rails的3.x中,可以防止初始化應用程序,並通過確保下面一行在你的config/application.rb中連接到數據庫:

config.assets.initialize_on_precompile = false 
+0

好吧,我應該在我原來的問題中包含該文件。我認爲這是某些人想要問的東西。我嚴格按照說明進行操作,並且我的代碼中已經有了該行。 – user2951507

+0

好的。我會仔細檢查是否有拼寫錯誤等。問題是,您在資產預先編譯期間連接到數據庫。現在,您可能會說資產預編譯不應該由於簽入清單而運行,但我認爲這是瞭解資產預編譯失敗的關鍵。由於嘗試連接數據庫失敗,這顯然是失敗的。 –

+0

因爲我已經在我的application.rb中有這一行這是否意味着heroku以某種方式忽略該行,仍然試圖連接到數據庫? – user2951507

相關問題