蓝图css rails 3.1帮助
我的蓝图css在我的本地机器上工作,但是当我推送到heroku时我得到一个错误。
我的蓝图存储在我的app/assets/stylesheets folder
,这里是我正在使用的样式表标签:
'screen' %> '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 XXXXXXXX@yahoo.com 2011-09-04T16:06:10+00:00 heroku[api]: Release v9 created by XXXXXXXX@yahoo.com 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: 2011-09-04T16:06:35+00:00 app[web.1]: 2: 'screen' %> 2011-09-04T16:06:35+00:00 app[web.1]: 3: '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 foxgrade@yahoo.com 2011-09-04T16:14:53+00:00 heroku[api]: Release v10 created by foxgrade@yahoo.com 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: 2011-09-04T16:15:02+00:00 app[web.1]: 2: 'screen' %> 2011-09-04T16:15:02+00:00 app[web.1]: 3: '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
我刚遇到同样的问题。 我通过在config/environments/production.rb
设置config.assets.compile = true
来解决它
编辑:这在开发时工作正常,但在运行时执行编译时性能下降。 请参阅下面的答案以获得更好的解决方案
解决此问题的一种方法是通过运行rake assets:precompile
来预编译rake assets:precompile
。 你必须通过添加包含一个javascript运行时
# 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
。
尝试设置你的:
config.assets.precompile += %w( blueprint/screen.css blueprint/print.css )
在config/environments/production.rb
我确信有比我更多经验的人可以告诉我们为什么所有的css文件都没有作为标准预编译。 我也刚刚开始!
这里至少有一个讨论: Rails 3.1资产管道 – 从公共/资产中丢失文件 – 为什么这不是默认值?
我试图运行rake资产:预编译并且无法使其工作。 我的Gemfile中有资产组。 我在某处读到了我应该确保预编译生产环境:
RAILS_ENV=production bundle exec rake assets:precompile
这也没有帮助。 我最终做了config.assets.compile = true,这很好,但我希望得到真正的解决方案。
在推送到他们说应该得到的heroku时,我从来没有得到-----> Preparing Rails asset pipeline
。
- 使用Amazon S3配置Carrierwave,在Heroku上托管
- Heroku总是运行资产:使用Rails 3.2的生产环境进行预编译
- DB上的错误:迁移“未初始化的常量DeviseCreateUsers”
- 通过Heroku上托管的Rails上传和解压缩文件到S3?
- 将ImageMagick CLI转换为MiniMagick gem
- 部署后将自定义CSS和Javascript链接到Rails
- 在Heroku(Rails)上创建文件时遇到问题
- 为什么有些JS行为在开发中有效,但是当我推送到Heroku时却没有?
- 如何调整在Heroku上运行的Ruby on Rails应用程序,它使用生产级Heroku Postgres?