rails资产没有被编译成一个文件?

时间:2011-11-23 23:44:53

标签: ruby-on-rails asset-pipeline

我的application.js文件:

//= require jquery
//= require jquery_ujs
//= require_tree ./includes
//= require global

我的布局文件:

<!DOCTYPE html>
<html>
<head>
  <title>Spectrum</title>
  <%= stylesheet_link_tag "application" %>
  <%= javascript_include_tag "application" %>
  <%= csrf_meta_tags %>
</head>
...

我的config / environments / development.rb文件:

# Expands the lines which load the assets
config.assets.debug = false

但是,当我在浏览器中加载页面时,所有js和css文件仍然是单独加载的:

<head>
  <title>Title!</title>


    <link href="/assets/application.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/utility.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/charting.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/global.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/home.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/questions.css?body=1" media="screen" rel="stylesheet" type="text/css" />
    <link href="/assets/scaffolds.css?body=1" media="screen" rel="stylesheet" type="text/css" />


    <script src="/assets/jquery.js?body=1" type="text/javascript"></script>

    <script src="/assets/jquery_ujs.js?body=1" type="text/javascript"></script>
    <script src="/assets/includes/includes.js?body=1" type="text/javascript"></script>
    <script src="/assets/global.js?body=1" type="text/javascript"></script>
    <script src="/assets/application.js?body=1" type="text/javascript"></script>

    <meta content="authenticity_token" name="csrf-param" />
    <meta content="kZEkjHQ/7PQ3zn95MJnHi0JJUk6b6b+6N2Uwejr3y6g=" name="csrf-token" />
</head>

3 个答案:

答案 0 :(得分:1)

来自rails guides

  

在开发模式下,资产按照清单文件中指定的顺序作为单独的文件提供。

答案 1 :(得分:1)

当前rails版本中必须为rails s -e production才能在生产模式下启动服务器。

答案 2 :(得分:0)

已修复...必须重新启动服务器,并且全部是&gt;&lt;