简体   繁体   中英

Rails asset pipeline isn't working

It seems that the Rails asset pipeline isn't functioning correctly in my development environment. I'm experiencing the following issues:

  1. Manifest files are being served in addition to other files.
  2. Files are not being concatenated.
  3. Some of the files that are served are completely empty.

These issues apply to both CSS and JavaScript assets. Below is a copy of the HTML output (I haven't edited the default rails layout). Note the presence of the manifest files and all the assets (which should be concatenated into a single file).

<!DOCTYPE html>
<html>
<head>
<title>Jackeyes</title>
<link href="/assets/application.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/home.css?body=1" media="all" rel="stylesheet" type="text/css" />
<link href="/assets/universal.css?body=1" media="all" 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/home.js?body=1" type="text/javascript"></script>
<script src="/assets/jquery.waitforimages.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="0AZh7mNJS7R1jsHKyZ5eKBrAON10Jra2677A8Lg3wzw=" name="csrf-token" />
</head>
<body>

I'm new to Rails, so I'm not sure how to begin resolving this. Any help would be greatly appreciated!

This is the default behaviour for rails in a development environment. I would suggest reading about asset pipeline in the rails guides .

During development, it tends to make things easier to debug if your assets are in separate files. For example, if you're using firebug in Firefox, you can look at each separate javascript file to see your compiled coffee output, set breakpoints, etc. It could also become inefficient to concatenate resources on each request, which tends to be important in a development environment where you're constantly changing assets and loading pages.

If you want to have everything concatenated while in development though, you set config.assets.debug = false in app/config/environments/development.rb .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM