This project is archived and is in readonly mode.

#6015 ✓resolved
Henning

AssetIncludeTag ensures that files are in the wrong directory

Reported by Henning | November 19th, 2010 @ 05:15 PM

javascript_include_tag and stylesheet_link_tag check that the included paths actually exist as files. Under certain circumstances this check is performed in the wrong directory and an error is raised even though all files exist.

The circumstances that expose this issue are:

  1. The included paths are named paths like 'script.js' (instead of :all)
  2. The asset tag helper is called with the :cache => true option
  3. config.perform_caching is set to false
  4. The application is running with a relative URL root ("sub-URI deployment")

The error that the paths correctly prefixed by the relative URL root are also used to check the files' existence. Since a path prefixed that way is a virtual path that does not exist in the local file system, that check fails.

My proposed fix is that paths used to check file existence should not be prefixed by the relative URL root. I will upload a patch with tests for this.

Steps to reproduce:

  1. Configure a Passenger application with RackBaseURI /sub-folder
  2. In the active application environment, set config.perform_caching = false
  3. In any view link to an existing javascript file: <%= javascript_include_tag 'script.js', :cache => true %><br/>
  4. Open that view in the browser
  5. You will see the follow error:

No such file or directory - Asset file not found at '/home/username/rails-project/public/sub-folder/javascripts/script.js'

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Referenced by

Pages