2013-05-31 54 views
0

我遵循rails教程chapter7,一切都很順利,直到我將代碼推送到heroku並按下「heroku open」命令時。然後嘗試運行命令$ heroku logs,得到了以下錯誤消息

2013-05-31T16:00:17.416309+00:00 app[web.1]: Rendered static_pages/home.html.erb within layouts/application (0.5ms) 
2013-05-31T16:00:17.431511+00:00 app[web.1]: 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  3: <head> 
2013-05-31T16:00:17.429902+00:00 app[web.1]: Completed 500 Internal Server Error in 14ms 
2013-05-31T16:00:17.431511+00:00 app[web.1]: ActionView::Template::Error (Invalid CSS after "5: ": expected "{", was "$grayMediumLigh..." 
2013-05-31T16:00:17.431511+00:00 app[web.1]: (in /app/app/assets/stylesheets/application.css)): 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  2: <html> 
2013-05-31T16:00:17.431761+00:00 app[web.1]: 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  4:  <title><%= full_title(yield(:title)) %></title> 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  6:  <%= javascript_include_tag "application" %> 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  5:  <%= stylesheet_link_tag "application", media: "all" %> 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  7:  <%= csrf_meta_tags %> 
2013-05-31T16:00:17.431511+00:00 app[web.1]:  8:  <%= render 'layouts/shim' %>  
2013-05-31T16:00:17.431761+00:00 app[web.1]: app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___1044640585478715857_42045460' 
2013-05-31T16:00:17.431761+00:00 app[web.1]: 
2013-05-31T16:00:18.589737+00:00 heroku[router]: at=info method=GET path=/favicon.ico host=shrouded-waters-7990.herokuapp.com fwd="106.147.82.192" dyno=web.1 connect=1ms service=4ms status=304 bytes=0 

我的源文件如下:

application.html.erb 

<!DOCTYPE html>                
<html>                  
    <head>                  
    <title><%= full_title(yield(:title)) %></title>       
    <%= stylesheet_link_tag "application", media: "all" %>     
    <%= javascript_include_tag "application" %>        
    <%= csrf_meta_tags %>              
    <%= render 'layouts/shim' %>            
    </head>                  
    <body>                  
    <%= render 'layouts/header' %>           
    <div class="container">             
     <% flash.each do |key, value| %>          
     <%= content_tag(:div, value, class: "alert alert-#{key}") %>   
     <% end %>                
     <%= yield %>               
     <%= render 'layouts/footer' %>           
     <%= debug(params) if Rails.env.development? %>       
    </div>                 
    </body>                  
</html> 

$grayMediumLight存在於文件custom.css.scss文件。它太冗長,所以我只是粘貼部分如下:

custom.css.scss 

@import "bootstrap";     

/* mixins, variables, etc. */   

$grayMediumLight: #eaeaea;    

@mixin box_sizing {      
    -moz-box-sizing: border-box;   
    -webkit-box-sizing: border-box;  
    box-sizing: border-box;    
}          
/* universal */       

html {         
    overflow-y: scroll;                    
}          

body {         
    padding-top: 60px;     
}          
..... 
+0

你有鏈接的教程?代碼看起來正確。 – Femaref

+0

http://ruby.railstutorial.org/chapters/sign-up,這是鏈接。而且我也將我的代碼推送到https://github.com/ryuever/sample_app – ryu

回答

0

提供您已經解決了問題,那麼你需要重新運行bundle exec rake assets:precompile RAILS_ENV=production,使資產能夠被編譯。正如您可能會發現,當您查看public/assets/custom.css.scss時,尚未進行更改。所以一旦你使用提供的命令預編譯你的資產並推送到Heroku主分支,這應該可以解決你的問題。

+0

它不起作用。順便說一句,我找不到文件'公共/資產/ custom.css.scss',在該文件夾中它只是只有三個文件,如** application-fe10468cdb685128eba66fc59c536a77.js ** – ryu

+0

@oda當你說它不工作,你是指'捆綁exec資產:預編譯RAILS_ENV =生產'?我相信通常當你預編譯你的資產時,你最終應該得到一個'application.css'文件,就像http://i.imgur.com/tGwKl6c.png – David

+0

抱歉讓你感到困惑,我的意思是即使我有重新編譯如你所說(可能它應該是'bundle exec rake assets:precompile RAILS_ENV = production'),但是這個問題仍然沒有解決。然後我發現所有的語句突然在文件'app/assets/stylesheets/application.css' – ryu