0

我正在关注rails教程第7章,一切都很顺利,直到我将代码推送到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;                   
}                                      
.....
4

1 回答 1

0

如果您已经解决了问题,那么您需要重新运行bundle exec rake assets:precompile RAILS_ENV=production以便可以编译资产。您可能会发现,当您查看您public/assets/custom.css.scss的更改尚未进行时。因此,一旦您使用提供的命令预编译资产并推送到 Heroku 主分支,这应该可以解决您的问题。

于 2013-05-31T16:52:58.683 回答