Update
更新
I got this error because I had a public.css and public.js file that was not compiled with the rest of the .css and .js files. The solution was to add this line to the production.rb file
我犯了这个错误,因为我有一个公众。css和公众。未与.css和.js文件一起编译的js文件。解决方案是将这条线添加到生产中。rb文件
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( public.js public.css )
As you see from the comment all files names application are already added. So, I just had to add the ones that was not called application.
从注释中可以看到,所有文件名称应用程序都已经添加。所以,我只需要添加那些不叫application的。
Hope it helps someone!
希望它能帮助一些人!
Original question
最初的问题
I have this gem file
我有这个宝石文件
gem 'rails', '3.1.0'
group :production do
gem 'pg'
end
group :development, :test do
gem 'sqlite3'
end
gem "heroku"
gem 'thin'
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'tabulous'
gem 'json'
gem "paperclip", "~> 2.4"
gem "devise"
gem "redcarpet"
group :assets do
gem 'uglifier'
end
gem 'jquery-rails'
gem "rspec-rails", :group => [:test, :development]
group :test do
end
when I deploy with "git push heroku master" I see this
当我使用“git push heroku master”部署时,我看到了这一点
Preparing app for Rails asset pipeline
Running: rake assets:precompile
mkdir -p /tmp/build_2m34y4hj01m4o/public/assets
mkdir -p /tmp/build_2m34y4hj01m4o/public/assets
mkdir -p /tmp/build_2m34y4hj01m4o/public/assets
mkdir -p /tmp/build_2m34y4hj01m4o/public/assets/admin
mkdir -p /tmp/build_2m34y4hj01m4o/public/assets/admin
-----> Rails plugin injection
Injecting rails_log_stdout
Injecting rails3_serve_static_assets
-----> Discovering process types
Procfile declares types -> (none)
Default types for Ruby/Rails -> console, rake, web, worker
-----> Compiled slug size is 31.2MB
-----> Launching... done, v5
http://maktaba.herokuapp.com deployed to Heroku
but in the heroku logs I get this ActionView::Template::Error. css isn't precompiled Strange.. I thougt it was looking at the deployment feedback
但是在heroku日志中,我得到了ActionView: Template: Error。css不是预编译奇怪. .我以为它是在看部署反馈
2011-11-23T22:59:48+00:00 app[web.1]: Rendered public/index.html.erb within layouts/first (0.7ms)
2011-11-23T22:59:48+00:00 app[web.1]: Completed 500 Internal Server Error in 30ms
2011-11-23T22:59:48+00:00 app[web.1]:
2011-11-23T22:59:48+00:00 app[web.1]: ActionView::Template::Error (public/public.css isn't precompiled):
2011-11-23T22:59:48+00:00 app[web.1]: 2: <html>
2011-11-23T22:59:48+00:00 app[web.1]: 3: <head>
2011-11-23T22:59:48+00:00 app[web.1]: 4: <title>Maktaba</title>
2011-11-23T22:59:48+00:00 app[web.1]: 5: <%= stylesheet_link_tag "public/public" %>
2011-11-23T22:59:48+00:00 app[web.1]: 6: <%= javascript_include_tag "public/public" %>
2011-11-23T22:59:48+00:00 app[web.1]: 7: <%= csrf_meta_tags %>
2011-11-23T22:59:48+00:00 app[web.1]: 8: <%= csrf_meta_tags %>
2011-11-23T22:59:48+00:00 app[web.1]: app/views/public/index.html.erb:5:in `_app_views_public_index_html_erb___1726244208117637261_45234420'
2011-11-23T22:59:48+00:00 app[web.1]: app/controllers/public_controller.rb:13:in `block (2 levels) in index'
2011-11-23T22:59:48+00:00 app[web.1]:
2011-11-23T22:59:48+00:00 app[web.1]: app/controllers/public_controller.rb:12:in `index'
Can any of you see what I am doing wrong?
你们能看出我做错了什么吗?
2 个解决方案
#1
18
- Run
bundle exec rake assets:precompile
on your local code - 运行bundle exec rake资产:在本地代码上预编译。
- Commit the changes and deploy to heroku
- 提交更改并部署到heroku
If this is your first time deploying your app to heroku, you may experience more errors after this is resolved. Let me know what happens.
如果这是您第一次将应用程序部署到heroku,那么在此之后您可能会遇到更多错误。告诉我发生了什么事。
#2
7
Actually, you need to run precompilation for your production environment:
实际上,您需要为您的生产环境运行预编译:
- Run
RAILS_ENV=production bundle exec rake assets:precompile
on local - 运行RAILS_ENV=生产bundle exec rake资产:在本地预编译
- Commit and deploy to Heroku
- 提交并部署到Heroku
More broadly, the Heroku docs describe three options for asset compilation for Rails 3.1+ on Cedar:
更广泛地说,Heroku文档描述了Rails 3.1+对Cedar的资产编译的三种选择:
- Compile locally (covered in this answer)
- 本地编译(在此答案中介绍)
- Compile during slug compilation
- 编译期间蛞蝓编译
- Compile during runtime
- 在运行时编译
#1
18
- Run
bundle exec rake assets:precompile
on your local code - 运行bundle exec rake资产:在本地代码上预编译。
- Commit the changes and deploy to heroku
- 提交更改并部署到heroku
If this is your first time deploying your app to heroku, you may experience more errors after this is resolved. Let me know what happens.
如果这是您第一次将应用程序部署到heroku,那么在此之后您可能会遇到更多错误。告诉我发生了什么事。
#2
7
Actually, you need to run precompilation for your production environment:
实际上,您需要为您的生产环境运行预编译:
- Run
RAILS_ENV=production bundle exec rake assets:precompile
on local - 运行RAILS_ENV=生产bundle exec rake资产:在本地预编译
- Commit and deploy to Heroku
- 提交并部署到Heroku
More broadly, the Heroku docs describe three options for asset compilation for Rails 3.1+ on Cedar:
更广泛地说,Heroku文档描述了Rails 3.1+对Cedar的资产编译的三种选择:
- Compile locally (covered in this answer)
- 本地编译(在此答案中介绍)
- Compile during slug compilation
- 编译期间蛞蝓编译
- Compile during runtime
- 在运行时编译