rails/rails — Issue #4535: Cannot load precompiled assets with periods within name
Author: phantomwhale
Created: 2012-01-19 06:24:55+00:00
State: open

I have found an issue with loaded precompiled assets that have at least two periods (.) in the name (e.g. more than just the one before the extension). For example, jquery,reveal.js

**Environment:** Rails 3.1.3, Ruby 1.9.2 (windows)

To recreate, create a new rails 3.1.3 project, create a basic controller / model scaffold (for simplicity) and migrate the production database

rails new period_asset_bug
cd period asset_bug
rails g scaffold widget
rake db:migrate RAILS_ENV="production"

Next add a file with at least two periods within it, such as jquery.reveal.js, to the app/assets/javascripts directory. Also add the following line to app/views/layouts/application.html.erb (or any view file) :

<%= javascript_include_tag "jquery.reveal" %>

Uncomment the following line next in config/environments/production.rb, and change it to include jquery.reveal.js in the precompilation assets

config.assets.precompile += %w( jquery.reveal.js )

Now precompile the assets, noting that this does create four files for jquerey.reveal in the public/assets directory, and then start the server

rake assets:precompile
rails s -e production

Navigate to `http://localhost:3000/widgets` - you will be presented with an error page, saying "jquery.reveal isn't precompiled"

As a workaround, you can either remove or replace the period in the filename. Alternatively, adding this file as part of a manifiest, instead of adding it directly into a page via the javascript_include_tag, also works around the issue.