2011-09-04 31 views
23

Css bản thiết kế của tôi hoạt động trên máy cục bộ của tôi, nhưng khi tôi chuyển sang heroku tôi gặp lỗi.đường ray css kế hoạch chi tiết 3.1 trợ giúp

Tôi đã kế hoạch chi tiết lưu trữ trong app/assets/stylesheets folder của tôi và đây là các thẻ stylesheet Tôi đang sử dụng:

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

Trong bản ghi Heroku của tôi, nó nói application.css isnt biên dịch sẵn và tôi nghĩ rằng đó có thể là lỗi, nhưng tôi không biết cách sửa nó.

Dưới đây là bản ghi Heroku tôi:

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 

Trả lời

27

Tôi chỉ có cùng một vấn đề. Tôi đã giải quyết nó bằng cách đặt config.assets.compile = true trong config/environments/production.rb

CHỈNH SỬA: Điều này làm việc tốt khi phát triển nhưng có hiệu suất như biên dịch được thực hiện trong thời gian chạy. Xem câu trả lời dưới đây để có giải pháp tốt hơn

+0

Tôi không thể cảm ơn đủ. cảm ơn rất nhiều! – John

+0

Không sao cả. Bắt đầu thử cả Heroku và Rails ngày hôm nay, vì vậy có thể có một cách khác. Tôi đoán một trong những thay vì nên biên dịch chúng lên phía trước bằng cách nào đó, mặc dù có vẻ như họ sẽ được lưu trữ anyway. – Arve

+0

Cảm ơn vì điều này - http://stackoverflow.com/questions/7443536/blueprint-screen-css-isnt-precompiled - không hoạt động. –

13

Một cách để khắc phục điều này là biên dịch trước nội dung bằng cách chạy rake assets:precompile. Bạn cần phải bao gồm một thời gian chạy javascript cho điều này bằng cách thêm

# 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 

đến Gemfile và chạy bundle install.

+1

Đối với người đọc trong tương lai: câu trả lời này lý tưởng hơn câu trả lời đã chọn. Các giải pháp hiệu suất cao là để biên dịch trước (như câu trả lời này nói), không phải để thiết lập compile = true. –

+7

Bạn cũng phải nói rõ Rails để bao gồm các tệp CSS Blueprint trong biên dịch trước. Để cấu hình/môi trường/production.rb, thêm 'config.assets.precompile + =% w (blueprint/screen.css kế hoạch chi tiết/print.css blueprint/ie.css)'. Xem http://stackoverflow.com/questions/7443536/blueprint-screen-css-isnt-precompiled. Sau đó biên dịch trước * để sản xuất * với 'RAILS_ENV = gói sản xuất exec rake asset: precompile'. Bài viết Heroku này giải thích ba tùy chọn để biên dịch nội dung: http://devcenter.heroku.com/articles/rails31_heroku_cedar. Làm tất cả điều này * trước khi * đẩy vào Heroku. –

+0

@MarkBerry cảm ơn bạn! Tôi đã có cùng một vấn đề và nó được giải quyết ngay bây giờ. Làm thế nào về hình ảnh họ cần phải được thêm vào quá? – lanan

0

Tôi đã cố gắng chạy tài sản rake: biên dịch trước và không thể làm cho nó hoạt động. Tôi có nhóm tài sản trong Gemfile của tôi. Tôi đọc ở đâu đó rằng tôi nên chắc chắn để hành tiền biên dịch env sản xuất:

RAILS_ENV=production bundle exec rake assets:precompile

đó không giúp được gì. Tôi đã làm config.assets.compile = true, nó hoạt động tốt, nhưng tôi rất muốn có giải pháp thực sự để làm việc.

Tôi không bao giờ nhận được số -----> Preparing Rails asset pipeline khi chuyển đến heroku mà họ nói người ta nên nhận.

2

Cố gắng thiết lập của bạn:

config.assets.precompile += %w(blueprint/screen.css blueprint/print.css) 

trong config/environments/production.rb

tôi chắc chắn rằng một người có nhiều kinh nghiệm hơn tôi có thể cho chúng tôi biết lý do tại sao tất cả các file css không trước biên soạn như là tiêu chuẩn. Tôi chỉ mới bắt đầu thôi!

Đây là ít nhất một cuộc thảo luận: Rails 3.1 asset pipeline - missing files from public/assets - why isn't this the default?

Các vấn đề liên quan