Rails 5 - 资产在生产中不起作用

时间:2016-09-09 21:56:24

标签: ruby-on-rails

我的应用程序在我的开发环境中本地运行正常,但是当我推送到Heroku时,或RAILS_ENV=production rails s我的一些JavaScript资产无效。例如,我正在使用cocoon gem和我在网上找到的datetimepicker(并放入vendor/assets/javascripts)。我已经RAILS_ENV=production rails assets:precompile运行了public/assets以及我在cocoon中看到的所有无效资产。另外,当我在我的页面上查看源代码并打开application.js文件时,我可以看出第三方JavaScript文件确实已编译到application.js中,因为我搜索了一些特定的字符串文字并查看它们。但TypeError: $(...).datetimepicker is not a function无效,我的浏览器控制台中显示application.js

我很难过,因为它们在我的开发环境中工作,并且所有资产似乎都被编译到production.rb文件中。关于如何解决这个问题甚至任何方向进一步解决问题的任何想法?

编辑:

所以我偶然发现了这个帖子:Disable Asset Minification in Rails Production,OP发布了

  

为了在我的heroku生产环境中调试javascript,我需要禁用资产压缩(或者至少压缩javascript)。

其中一条评论建议在config.assets.js_compressor = :uglifier config.assets.debug = true中注释掉这一行并添加uglifier。我做到了这一点,BAM一切正常。为什么是这样? @echo off setlocal enableextensions, enabledelayedexpansion set _FOLDER="C:\Temp" set /a _FILES=0 set /a _DIRS=0 call :handle_dir %_FOLDER% echo Dirs: %_DIRS%, Files: %_FILES% goto :eof :handle_dir set /a _DIRS=%_DIRS%+1 for /f %%f in ('dir /b /a:-d "%~1" 2^>nul') do ( set /a _FILES=!_FILES!+1 ) for /f %%f in ('dir /b /a:d "%~1"') do ( call :handle_dir "%~1\%%f" ) goto :eof 如何破坏我的代码?

0 个答案:

没有答案
相关问题