2012-04-08 87 views
2

上傳我的Ruby on Rails的應用的Heroku導致以下錯誤:Heroku「我們很抱歉,但出了點問題。」由於javascript_include_tag

We're sorry, but something went wrong.

這並不是我的本地機器上進行。

經過一番調試,我想我可能已經發現了錯誤,但不知道如何解決它。

在我的文件application.html.erb中,刪除以下行解決了這個問題,但是我的應用程序丟失了它的jquery移動主題。任何想法我可以做什麼來解決這個問題?

行導致該問題:

<%= javascript_include_tag "application" %> 

application.html.erb文件:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Washapp</title> 
    <meta name="viewport" content="width=device-width"> 
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> 
    <%= javascript_include_tag "application" %> 

    <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> 
    <%= csrf_meta_tags %> 

    <script> 
    if (window.location.hash == "#_=_") 
     window.location.hash = ""; 
    </script> 

</head> 
<body> 
    <div data-role="page"> 
    <%= yield %> 
    </div> 
</body> 
</html> 

Heroku的日誌:

2012-04-08T23:28:41+00:00 heroku[nginx]: 78.105.51.57 - - [08/Apr/2012:23:28:41 +0000] "GET/HTTP/1.1" 500 643 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.151 Safari/535.19" washappdelete2.heroku.com 
2012-04-08T23:28:43+00:00 app[web.1]: 
2012-04-08T23:28:43+00:00 app[web.1]: Started GET "/" for 78.105.51.57 at 2012-04-08 16:28:43 -0700 
2012-04-08T23:28:43+00:00 app[web.1]: 
2012-04-08T23:28:43+00:00 app[web.1]: Processing by HomeController#index as HTML 
2012-04-08T23:28:43+00:00 app[web.1]: Rendered home/routa_list.html.erb within layouts/application (0.1ms) 
2012-04-08T23:28:43+00:00 app[web.1]: Completed 500 Internal Server Error in 34ms 
2012-04-08T23:28:43+00:00 app[web.1]: 
2012-04-08T23:28:43+00:00 app[web.1]:  4: <title>Washapp</title> 
2012-04-08T23:28:43+00:00 app[web.1]: ActionView::Template::Error (application.js isn't precompiled): 
2012-04-08T23:28:43+00:00 app[web.1]:  5: <meta name="viewport" content="width=device-width"> 
2012-04-08T23:28:43+00:00 app[web.1]:  6: <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.css" /> 
2012-04-08T23:28:43+00:00 app[web.1]:  7: <%= javascript_include_tag "application" %> 
2012-04-08T23:28:43+00:00 app[web.1]:  9: <script src="http://code.jquery.com/mobile/1.0.1/jquery.mobile-1.0.1.min.js"></script> 
2012-04-08T23:28:43+00:00 app[web.1]:  8: 
2012-04-08T23:28:43+00:00 app[web.1]:  10: <%= csrf_meta_tags %> 
2012-04-08T23:28:43+00:00 app[web.1]: app/views/layouts/application.html.erb:7:in `_app_views_layouts_application_html_erb__2373145142857118006_42724320' 
2012-04-08T23:28:43+00:00 app[web.1]: app/controllers/home_controller.rb:4:in `index' 
2012-04-08T23:28:43+00:00 app[web.1]: cache: [GET /] miss 
2012-04-08T23:28:43+00:00 app[web.1]: 
2012-04-08T23:28:43+00:00 app[web.1]: 

應用程序/資產/ Java腳本/ application.js中

// This is a manifest file that'll be compiled into application.js, which will include all the files 
// listed below. 
// 
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 
// 
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 
// the compiled file. 
// 
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 
// GO AFTER THE REQUIRES BELOW. 
// 
//= require jquery 
//= require jquery_ujs 
//= require_tree . 

https://github.com/karangb/herokuProblem

+0

什麼版本的軌道您使用的是?可能與資產管道有關。資產的包含方式取決於您所處的環境。http://guides.rubyonrails.org/asset_pipeline.html – benjgorman 2012-04-08 23:21:24

+0

我正在運行Rails 3.2.2 – Karan 2012-04-08 23:22:52

+0

是的,它與您的資產編譯有關。閱讀我發佈的鏈接。 – benjgorman 2012-04-08 23:23:43

回答

7

問題解決了!

很簡單 - 從500 internal server error when I try to push my app onto Heroku

So based upon the heroku info that you provided I see that you are on the bamboo stack and that stack does not support Rails 3.1+. Only the cedar stack supports Rails 3.1+. You'll need to use the following command to create a new app on the cedar stack:

heroku create --stack cedar

+0

所以最終唯一能解決這個問題的人就是你或者Heroku。 *嘆*至少這篇文章將有一個很好的全面的目的。我建議如果您發現我們的回覆中的大部分內容都有用,請給予適當的獎勵。 – Jonathan 2012-04-09 01:30:17

+0

是的,不幸的是。花上幾小時 - 希望heroku日誌更好。 非常感謝。這裏提供的支持鼓勵我繼續前進! :) – Karan 2012-04-09 01:33:19

+3

耶,救了那天,卡蘭!在重新運行'git push heroku master'和'heroku run rake db:migrate'之前,只需將'.git/config'中的** url **更改爲[remote「heroku」]部分... – 2012-11-25 03:55:25

0

嘗試在配置/ enviroments設置/ production.rb以下行假:

config.assets.compile = false 
+0

嗯......該行已經在我的production.rb中 - 我可能已經在之前添加過......仍導致錯誤... – Karan 2012-04-08 23:25:11

+0

你的application.js文件的內容是什麼? – benjgorman 2012-04-08 23:25:45

+0

// =要求jquery // =要求jquery_ujs // = require_tree。 – Karan 2012-04-08 23:30:39

1

嘗試加入

//= require jquery.mobile

app/assets/stylesheets/application.js

AMD

設置

config.assets.compile = tue

config/enviroments/production.rb

+0

好的,我會馬上更新我的結果 – Karan 2012-04-08 23:34:12

+0

如果這不起作用,請將'app/assets'中的文件和文件夾的名稱添加到您的問題 – Jonathan 2012-04-08 23:36:39

+0

其實你可能不得不使用寶石「jquery-mobile-rails」來完成這項工作。 – benjgorman 2012-04-08 23:37:12

0

如果你有anyt hing像javaapp/assets之內,這會讓鏈輪脫落。將它命名爲類似的小程序將允許編譯javascripts目錄的內容。 Source

+0

我不認爲我的應用程序/資產中有類似java的東西。我有 - 圖片 ---導軌。PNG - JavaScript的 --- application.js中 --- home.js.coffee --- users.js.coffee - 樣式 --- application.css --- home.css.scss - - scaffolds.css.scss --- users.css.scss – Karan 2012-04-08 23:45:45

0

您還設置

config.assets.initialize_on_precompile = false 

這是on Rails的3新的變化。2(見Docs

然而,你應該能夠蛞蝓在編譯期間看到錯誤(如下面的例子,如果你沒有設置上述標誌)

-----> 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? 

您也可以嘗試在本地運行rake預編譯任務,並查看錯誤(同樣,文檔正在建議)。

+0

該設置已經在我的文件中設置了...... – Karan 2012-04-09 00:01:34

+0

所以你嘗試'rake assets:precompile'來查看你是否在本地遇到問題? – Jonathan 2012-04-09 00:07:17

3

採取在配置/ application.rb中,添加

config.assets.initialize_on_precompile = false 

,並推到git的,然後推的Heroku。

+0

這樣做對我來說,謝謝你的提示 – Thomas 2013-01-19 20:21:21

0

確保沒有任何未經跟蹤的文件,做git status

也許嘗試,heroku run rake db:migrate

相關問題