javascript_include_tag Rails 4 generating “/javascripts/” instead of “/assets” in production

后端 未结 5 1763
野趣味
野趣味 2021-02-01 02:31

I have a Rails 4 application with

<%= javascript_include_tag \"modernizr\", \"data-turbolinks-track\" => true %>

in the head. In deve

5条回答
  •  孤城傲影
    2021-02-01 03:27

    One of the usage statements for AssetUrlHelper indicates it will produce /javascripts/ urls like what you are seeing:

    # asset_path "application", type: :javascript # => /javascripts/application.js

    (from asset_url_helper.rb line 117 - [1])

    This code looks like it can only be reached if the precompiled asset is missing so it would appear that your asset compilation is not working (my deployments usually fail when that happens, so maybe yours isn't even firing).

    The same asset_url_helper.rb calls the /javascripts/ part 'extname' and uses the following map to know how to generate the name:

     # Maps asset types to public directory.
      ASSET_PUBLIC_DIRECTORIES = {
        audio:      '/audios',
        font:       '/fonts',
        image:      '/images',
        javascript: '/javascripts',
        stylesheet: '/stylesheets',
        video:      '/videos'
      }
    

    A new Rails 4 app has this in the config/environments/production.rb

      # Do not fallback to assets pipeline if a precompiled asset is missed.
      config.assets.compile = false
    

    which seems to match the behavior you are seeing.

提交回复
热议问题