Heroku无法在我的Ruby on Rails应用程序中找到文件 - 即使它们在那里? [英] Heroku can't find files in my Ruby on Rails app - even though they are right there?

查看:132
本文介绍了Heroku无法在我的Ruby on Rails应用程序中找到文件 - 即使它们在那里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试访问我的网站时,检查我的Heroku日志,我看到这个错误:


ActionView :: Template ::错误(无法找到'重置'文件
2012-06-13T02:31:43 + 00:00 app [web.1] :(在
/ app / app / assets / stylesheets / application中.css:4)):





我还建议您在生产环境中本地尝试资产预编译 RAILS_ENV =生产捆绑包exec rake资产:预编译



最后,您可能需要查看以下不同链接以查找有用信息:




When I try to access my site, then check my Heroku logs, I see this error:

ActionView::Template::Error (couldn't find file 'reset' 2012-06-13T02:31:43+00:00 app[web.1]: (in /app/app/assets/stylesheets/application.css:4)):

(application.css contains the line *= require reset)

Then I thought to run "heroku run bundle exec rake assets:precompile:all" but this gives a similar error:

-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       rake aborted!
       couldn't find file 'main/first.js.coffee'
       (in /tmp/build_3428u21sggsoc/app/assets/javascripts/application.js:1)
       Tasks: TOP => assets:precompile:primary

(That file is the first one required from my application.js, which has first line "//= require main/first.js.coffee")

In summary: my application runs fine locally, but when I deploy to Heroku, the files can no longer be found. Any ideas why?

Edit: here is the project tree. (There is one more directory before the app one, and that is the main project directory that also contains config, db, log, etc)

Another edit: there is no problem with .gitignore, or .slugignore.

解决方案

At first, I would suggest you to run your application in production mode on your local computer. There are some errors (in assets but I also found some in routing) which can have impact only for production environment so you can test and fix them locally instead of having to do it from the production server.

About the asset precompilation on Heroku, the solution given by akjoe should result in compiled assets tracked in git repo : with this option, you should disable the asset precompilation which happen on Heroku and let Rails serve you assets (set config.serve_static_assets = true in your production.rb file) but this is not the best way to deal with the asset pipeline as you lost one of his major benefice which is freeing your rails application of request for asset. To make it working properly, you should setup something like heroku explain : Using Rack::Cache with Memcached for Static Asset Caching in Rails 3.1+

I would also suggest you to try the assets precompilation locally in production environment RAILS_ENV=production bundle exec rake assets:precompile. To see if you got any error.

Finally you may want to check this different links to find useful information :

这篇关于Heroku无法在我的Ruby on Rails应用程序中找到文件 - 即使它们在那里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆