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

后端 未结 5 1795
野趣味
野趣味 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:03

    By default, Rails only precompiles application.js, application.css and any images it finds in the assets path. Therefore, in production mordernizr will not get precompiled and thus the javascript helpers will not be able to find the file.

    In order to fix the issue, you can add modernizr to the precompile list by modifying the following config in production.rb

    config.assets.precompile += ['modernizr.js']
    

    For more information see the Rails Guides

提交回复
热议问题