# Asset pipeline question

**URL:** <https://www.ruby-forum.com/t/asset-pipeline-question/211500>\
**Category:** Rails\
**Created:** [September 5, 2011, 11:51pm UTC](https://www.ruby-forum.com/t/asset-pipeline-question/211500 "2011-09-05T23:51:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [September 5, 2011, 11:51pm UTC](https://www.ruby-forum.com/t/asset-pipeline-question/211500/1 "2011-09-05T23:51:23Z")

</div>

Hello…I’ve run into some behavior I didn’t expect with the asset  
pipeline, running rails 3.1.0 (released version).

In my environments/production.rb I have:

config.assets.compile = false  
config.assets.digest = true

When I precompile my assets, all seems to work fine; it generates  
assets with digests in their name, and I can retrieve them with  
something like

/assets/tvlogo1-0ac8bb18dbc4d72f65d626985535fd22.png

When I retrieve the above, it’s served from apache.

Somewhat unexpectedly, I can also successfully retrieve:

/assets/tvlogo1.png

There is no such file in the public/assets directory, but it  
successfully retrieves the file and serves it through rack/rails (I  
can see the request in the production.log file).

Is this expected behavior?

It’s convenient, in that I can use my application.css from, say,  
static HTML files like my 404.html and 500.html pages, but I didn’t  
expect it to work given that I have config.assets.compile=false.

Thanks,

Greg

---

<div class="post-metadata">

**Author:** ![gr2020](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c68b51/32.png) [@gr2020](https://www.ruby-forum.com/u/gr2020)\
**Post date:** [September 6, 2011, 5:11pm UTC](https://www.ruby-forum.com/t/asset-pipeline-question/211500/2 "2011-09-06T17:11:02Z")

</div>

Perhaps I could restate this question more simply.

If the asset pipeline is in digest mode (in production), is it expected  
behavior that it should also serve assets _without_ digests in their  
filenames?

-GR

---

<div class="post-metadata">

**Author:** ![gr2020](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/c68b51/32.png) [@gr2020](https://www.ruby-forum.com/u/gr2020)\
**Post date:** [September 6, 2011, 6:25pm UTC](https://www.ruby-forum.com/t/asset-pipeline-question/211500/3 "2011-09-06T18:25:45Z")

</div>

Following up some more on my own question…looks like someone added a  
pull request today that directly addresses this. Will keep an eye on  
it, though…if this gets “fixed”, I think it will complicate things  
like a 404.html page that uses the application css file.

> <https://github.com/rails/rails/pull/2886>
>
> During discussions on \`#RubyOnRails\`, it was discovered that when \`config.assets….compile\` is set to \`false\`, assets are still compiled under the following conditions:
> 1. \`config.serve\_static\_assets\` is set to \`false\` (the default in production) and any request is made for an asset
> 2. any request is made for an asset without digest (irrespective of the value of \`config.serve\_static\_assets\`)
> 
> This pull request contains a patch to only mount the asset server if \`config.assets.compile\` is set to \`true\`. In the instance that it is set to \`false\`, and a request is made as outlined above, the user agent will receive a 404.
> 
> A test for the patch, \_"assets routes are not drawn when compilation is disabled"\_, is included, as is a small change to the existing test \_"assets do not require any assets group gem when manifest file is present"\_ which now serves the precompiled asset statically rather than via the assets server.
> 
> (Additional credit due to \`cachemoney\` on \`#RubyOnRails\` for working on this with me.)
