Skip to content

javascript_include_tag does not add '.js' extension to sources that contain a '.' #3715

@kranzky

Description

@kranzky

We've just hit this in production in 3.1.1, with the following line of code:

  <%= javascript_include_tag "jquery.signaturepad" %>

Even though jquery.signaturepad.js appears in our manifest.yml, the code raises an AssetNotPrecompiledError.

The problem is that Sprockets::Helpers::RailsHelper::AssetPaths.rewrite_extension does not append the '.js' extension to the source unless File.extname(source).empty?

Obviously the fix for us is trivial; just manually add the '.js' extension. However, this is counter-intuitive, as manifest files such as the one below work just fine without needing to be explicit about the extension:

//= require jquery.autocomplete
//= require jquery.form
//= require jquery.remotipart
//= require jquery.placeholder

Perhaps the extension could be added if File.extname(source) != ext, or perhaps javascript_include_tag could try both versions (with and without the extension), and fail only if both aren't present?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions