本文介绍了生产中的Rails资产的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚迁移到Rails 3.1,但是在资产管道入门方面遇到了麻烦.

I've just migrated to rails 3.1 and I'm having trouble getting started with the asset pipeline.

我运行:bundle exec rake assets:precompile RAILS_ENV=production将其他css文件添加到config.assets.precompile += ['scaffold.css', 'other.css', 'other.js']后,我所有的文件都位于/app/asset图像,javascript或样式表路径中.

I ran: bundle exec rake assets:precompile RAILS_ENV=production after adding additional css files into config.assets.precompile += ['scaffold.css', 'other.css', 'other.js'] all of my files are located in the /app/asset images, javascripts, or stylesheets path.

在执行rake任务之后,我可以看到manifest.yml文件,但是它缺少我添加到config.assets.precompile

Following the rake task, I can see the manifest.yml file but it is missing the additional css and js files I added to the config.assets.precompile

这是我放在清单上的manifest.yml文件:

Here is my manifest.yml file that lives on prod:

这是怎么回事?我已经用touch restart.txt和nginx重新启动了这两个乘客.我已经阅读了有关此问题的所有文档.

What is going on here? I've restarted both passenger with touch restart.txt and nginx. I've read all of the documentation on this issue.

nginx error.log:

cache: [GET /] miss

ActionView::Template::Error (scaffold.css isn't precompiled):
    2: %html
    3:   %head
    4:     %title redmeetsblue
    5:
    6:     = javascript_include_tag "application.js"
    7:     = csrf_meta_tag
    8:     %script{:src => "http://connect.facebook.net/en_US/all.js#appId=143150285757259&xfbml=1"}
  app/views/layouts/application.html.haml:5:in `_app_views_layouts_application_html_haml__44133251_81438200'
  app/controllers/homes_controller.rb:7:in `index'

推荐答案

是否已在application.rb中设置config.assets.precompile值?如果将它们设置在其他位置,则在您进行预编译时不会选择它们.

Have you set the config.assets.precompile values in application.rb ? If you set them elsewhere they won't be picked up when you precompile.

这篇关于生产中的Rails资产的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-03 08:59