2013-03-24 51 views
1

我在生產導軌網站上收到500內部服務器錯誤,這是我在logs/production.log上看到的。令人驚訝的代碼在開發中的本地服務器上工作500內部服務器錯誤 - 導軌生產中的ActionView :: Template :: Error

Completed 500 Internal Server Error in 11745ms 

ActionView::Template::Error (undefined method `[]' for nil:NilClass 
    (in /home/jason/public_html/site/app/assets/stylesheets/application.css)): 
    8:  
    9:  <%= csrf_meta_tags %> 
    10: 
    11:  <%= stylesheet_link_tag "application", :media => "all" %> 
    12: 
    13: </head> 
    14: <body> 
    app/views/layouts/application.html.erb:11:in `_app_views_layouts_application_html_erb__243082314235891573_4889460' 
    app/controllers/main_controller.rb:18:in `index' 

我在這裏迷路了,有什麼幫助嗎?

這裏是Application.css

/* You're free to add application-wide styles to this file and they'll appear at the top of the 
* compiled file, but it's generally better to create a new file per style scope. 
* 
*= require_tree . 
*= require_self 
*/ 

/* Main Body */ 

body { 
    background: #f3f3f3; 
} 
+1

也許你需要在推向生產時預先編譯資產 – fengd 2013-03-24 07:30:40

+0

@ Jun1st-如何在生產環境中預編譯資產? – iCyborg 2013-03-24 07:37:35

+0

bundle exec rake資源:預編譯。你應該把「如何預編譯...」放到谷歌搜索框中,而不是在這裏詢問:) – fengd 2013-03-24 07:41:39

回答

3

需要預編譯的資產當推到生產

bundle exec rake assets:precompile 

也,讀asset pipeline DOC一些,值得你花時間

+0

我運行bundle exec rake assets:precompile,但得到這個錯誤「rake aborted!undefined method'[ ]'爲nil:NilClass(在/home/jason/public_html/mysite/app/assets/stylesheets/application.css)「,所以基本上與上面相同的錯誤。 – iCyborg 2013-03-24 09:05:00

+0

終於我得到它解決,謝謝,我當然要通過資產管道,以充分了解它 – iCyborg 2013-03-24 11:27:56

+1

高興你修好了:) – fengd 2013-03-24 15:19:17

相關問題