2011-09-04 86 views
23

我的藍圖css在我的本地機器上運行,但是當我推送到heroku時,出現錯誤。藍圖css rails 3.1幫助

我已經藍圖保存在我的app/assets/stylesheets folder,這裏是我使用的樣式表標籤:

<%= stylesheet_link_tag "application" %> 
<%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> 
<%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> 

在我的Heroku的日誌,它說application.css心不是預編譯,並且我認爲這可能是錯誤,但我不知道如何解決它。

這裏是我的Heroku的日誌:

2011-09-04T07:35:59+00:00 heroku[web.1]: Idling 
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from up to down 
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from down to created 
2011-09-04T07:36:00+00:00 heroku[web.1]: State changed from created to starting 
2011-09-04T07:36:01+00:00 heroku[web.1]: Stopping process with SIGTERM 
2011-09-04T07:36:01+00:00 app[web.1]: >> Stopping ... 
2011-09-04T07:36:01+00:00 heroku[web.1]: Process exited 
2011-09-04T07:36:04+00:00 heroku[web.1]: Starting process with command `thin -p 44288 -e production -R /home/heroku_rack/heroku.ru start` 
2011-09-04T07:36:07+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious) 
2011-09-04T07:36:07+00:00 app[web.1]: >> Maximum connections set to 1024 
2011-09-04T07:36:07+00:00 app[web.1]: >> Listening on 0.0.0.0:44288, CTRL+C to stop 
2011-09-04T07:36:08+00:00 heroku[web.1]: State changed from starting to up 
2011-09-04T08:41:45+00:00 heroku[web.1]: Idling 
2011-09-04T08:41:46+00:00 heroku[web.1]: State changed from up to down 
2011-09-04T08:41:46+00:00 heroku[web.1]: Stopping process with SIGTERM 
2011-09-04T08:41:46+00:00 app[web.1]: >> Stopping ... 
2011-09-04T08:41:47+00:00 heroku[web.1]: Process exited 
2011-09-04T16:05:59+00:00 heroku[slugc]: Slug compilation started 
2011-09-04T16:06:10+00:00 heroku[api]: Deploy 9ec665f by [email protected] 
2011-09-04T16:06:10+00:00 heroku[api]: Release v9 created by [email protected] 
2011-09-04T16:06:11+00:00 heroku[slugc]: Slug compilation finished 
2011-09-04T16:06:19+00:00 heroku[web.1]: Unidling 
2011-09-04T16:06:19+00:00 heroku[web.1]: State changed from down to created 
2011-09-04T16:06:19+00:00 heroku[web.1]: State changed from created to starting 
2011-09-04T16:06:21+00:00 heroku[web.1]: Starting process with command `thin -p 32066 -e production -R /home/heroku_rack/heroku.ru start` 
2011-09-04T16:06:25+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious) 
2011-09-04T16:06:25+00:00 app[web.1]: >> Maximum connections set to 1024 
2011-09-04T16:06:25+00:00 app[web.1]: >> Listening on 0.0.0.0:32066, CTRL+C to stop 
2011-09-04T16:06:26+00:00 heroku[web.1]: State changed from starting to up 
2011-09-04T16:06:27+00:00 app[web.1]: 
2011-09-04T16:06:27+00:00 app[web.1]: 
2011-09-04T16:06:27+00:00 app[web.1]: Started GET "/" for 65.7.186.42 at 2011-09-04 09:06:27 -0700 
2011-09-04T16:06:28+00:00 app[web.1]: 
2011-09-04T16:06:28+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 
2011-09-04T16:06:28+00:00 app[web.1]: 
2011-09-04T16:06:28+00:00 app[web.1]: 
2011-09-04T16:06:28+00:00 app[web.1]: 
2011-09-04T16:06:28+00:00 app[web.1]: cache: [GET /] miss 
2011-09-04T16:06:28+00:00 heroku[router]: GET corporatefox.heroku.com/ dyno=web.1 queue=0 wait=0ms service=754ms status=404 bytes=728 
2011-09-04T16:06:28+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:28 -0700] "GET/HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com 
2011-09-04T16:06:35+00:00 app[web.1]: 
2011-09-04T16:06:35+00:00 app[web.1]: 
2011-09-04T16:06:35+00:00 app[web.1]: Started GET "/pages/home" for 65.7.186.42 at 2011-09-04 09:06:35 -0700 
2011-09-04T16:06:35+00:00 app[web.1]: Processing by PagesController#home as HTML 
2011-09-04T16:06:35+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (17.0ms) 
2011-09-04T16:06:35+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (25.3ms) 
2011-09-04T16:06:35+00:00 app[web.1]: Completed 500 Internal Server Error in 92ms 
2011-09-04T16:06:35+00:00 app[web.1]: 
2011-09-04T16:06:35+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled): 
2011-09-04T16:06:35+00:00 app[web.1]:  1: <%= stylesheet_link_tag 'application' %> 
2011-09-04T16:06:35+00:00 app[web.1]:  2: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> 
2011-09-04T16:06:35+00:00 app[web.1]:  3: <%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> 
2011-09-04T16:06:35+00:00 app[web.1]: app/views/layouts/_stylesheets.html.erb:1:in `_app_views_layouts__stylesheets_html_erb__1720273165801032019_31408840' 
2011-09-04T16:06:35+00:00 app[web.1]: app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb___1444640675865794326_32133320' 
2011-09-04T16:06:35+00:00 app[web.1]: 
2011-09-04T16:06:35+00:00 app[web.1]: 
2011-09-04T16:06:35+00:00 app[web.1]: cache: [GET /pages/home] miss 
2011-09-04T16:06:35+00:00 heroku[router]: GET corporatefox.heroku.com/pages/home dyno=web.1 queue=0 wait=0ms service=120ms status=500 bytes=728 
2011-09-04T16:06:35+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:35 -0700] "GET /pages/home HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: Started GET "/" for 65.7.186.42 at 2011-09-04 09:06:42 -0700 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: ActionController::RoutingError (No route matches [GET] "/"): 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: 
2011-09-04T16:06:42+00:00 app[web.1]: cache: [GET /] miss 
2011-09-04T16:06:42+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:06:42 -0700] "GET/HTTP/1.1" 404 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com 
2011-09-04T16:14:42+00:00 heroku[slugc]: Slug compilation started 
2011-09-04T16:14:53+00:00 heroku[api]: Deploy 2fed989 by [email protected] 
2011-09-04T16:14:53+00:00 heroku[api]: Release v10 created by [email protected] 
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from up to bouncing 
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from bouncing to created 
2011-09-04T16:14:54+00:00 heroku[web.1]: State changed from created to starting 
2011-09-04T16:14:54+00:00 heroku[slugc]: Slug compilation finished 
2011-09-04T16:14:56+00:00 heroku[web.1]: Stopping process with SIGTERM 
2011-09-04T16:14:56+00:00 app[web.1]: >> Stopping ... 
2011-09-04T16:14:57+00:00 heroku[web.1]: Process exited 
2011-09-04T16:14:57+00:00 heroku[web.1]: Starting process with command `thin -p 48112 -e production -R /home/heroku_rack/heroku.ru start` 
2011-09-04T16:15:01+00:00 app[web.1]: >> Thin web server (v1.2.6 codename Crazy Delicious) 
2011-09-04T16:15:01+00:00 app[web.1]: >> Maximum connections set to 1024 
2011-09-04T16:15:01+00:00 app[web.1]: >> Listening on 0.0.0.0:48112, CTRL+C to stop 
2011-09-04T16:15:01+00:00 heroku[web.1]: State changed from starting to up 
2011-09-04T16:15:02+00:00 app[web.1]: Processing by PagesController#home as HTML 
2011-09-04T16:15:02+00:00 app[web.1]: Rendered pages/home.html.erb within layouts/application (13.2ms) 
2011-09-04T16:15:02+00:00 app[web.1]: Rendered layouts/_stylesheets.html.erb (24.1ms) 
2011-09-04T16:15:02+00:00 app[web.1]: Completed 500 Internal Server Error in 86ms 
2011-09-04T16:15:02+00:00 app[web.1]: 
2011-09-04T16:15:02+00:00 app[web.1]: ActionView::Template::Error (application.css isn't precompiled): 
2011-09-04T16:15:02+00:00 app[web.1]:  1: <%= stylesheet_link_tag "application" %> 
2011-09-04T16:15:02+00:00 app[web.1]:  2: <%= stylesheet_link_tag 'blueprint/screen', :media => 'screen' %> 
2011-09-04T16:15:02+00:00 app[web.1]:  3: <%= stylesheet_link_tag 'blueprint/print', :media => 'print' %> 
2011-09-04T16:15:02+00:00 heroku[router]: GET corporatefox.heroku.com/pages/home dyno=web.1 queue=0 wait=0ms service=755ms status=500 bytes=728 
2011-09-04T16:15:02+00:00 app[web.1]: app/views/layouts/_stylesheets.html.erb:1:in `_app_views_layouts__stylesheets_html_erb__4527639971944011061_33003340' 
2011-09-04T16:15:02+00:00 app[web.1]: app/views/layouts/application.html.erb:5:in `_app_views_layouts_application_html_erb__2040511387187567951_33642800' 
2011-09-04T16:15:02+00:00 app[web.1]: 
2011-09-04T16:15:02+00:00 app[web.1]: 
2011-09-04T16:15:02+00:00 app[web.1]: cache: [GET /pages/home] miss 
2011-09-04T16:15:02+00:00 heroku[nginx]: 65.7.186.42 - - [04/Sep/2011:09:15:02 -0700] "GET /pages/home HTTP/1.1" 500 728 "-" "Mozilla/5.0 (X11; Linux i686) AppleWebKit/534.30 (KHTML, like Gecko) Chrome/12.0.742.112 Safari/534.30" corporatefox.heroku.com 

回答

27

我有同樣的問題。我解決它在config/environments/production.rb

編輯設置config.assets.compile = true:這工作,同時發展精細,但作爲編輯在運行時進行有性能損失。請參閱下面的答案以獲得更好的解決方案

+0

我不能感謝你纔好。非常感謝! – John

+0

沒問題。今天開始嘗試Heroku和Rails,所以可能有另一種方法。我想我們應該儘可能地將它們編譯出來,儘管看起來它們會被緩存。 – Arve

+0

感謝這一個 - http://stackoverflow.com/questions/7443536/blueprint-screen-css-isnt-precompiled - 沒有工作。 –

13

解決此問題的一種方法是通過運行rake assets:precompile預編譯資產。您可以通過添加

# Gems used only for assets and not required 
# in production environments by default. 
group :assets do 
    gem 'therubyracer' 
    gem 'sass-rails', " ~> 3.1.0" 
    gem 'coffee-rails', "~> 3.1.0"a 
    gem 'uglifier' 
end 

Gemfile和運行bundle install以包括這樣的JavaScript運行。

+1

對於未來的讀者:這個答案比選擇的答案更理想。高性能的解決方案是預編譯(如本答案所述),而不是設置compile = true。 –

+7

您還必須明確告訴Rails在預編譯中包含Blueprint CSS文件。要配置/ environments/production.rb,添加'config.assets.precompile + =%w(blueprint/screen.css blueprint/print.css blueprint/ie.css)'。請參閱http://stackoverflow.com/questions/7443536/blueprint-screen-css-isnt-precompiled。然後使用'RAILS_ENV =生產包exec rake資產:預編譯'預編譯*進行生產*。這篇Heroku文章解釋了編譯資產的三個選項:http://devcenter.heroku.com/articles/rails31_heroku_cedar。在推向Heroku之前,先做所有這些事情。 –

+0

@MarkBerry謝謝!我有同樣的問題,現在解決了。他們還需要添加圖像怎麼樣? – lanan

0

我試圖運行rake資源:預編譯,無法讓它工作。我在Gemfile中擁有資產組。我讀的地方,我應該確保預編譯的生產ENV:

RAILS_ENV=production bundle exec rake assets:precompile

這並沒有幫助。我最終做了config.assets.compile = true,它工作正常,但我很想得到真正的解決方案。

當我推薦他們說應該得到的heroku時,我永遠不會得到-----> Preparing Rails asset pipeline