在rails中查找coffescript错误的行号

Jul*_*ard 5 debugging ruby-on-rails coffeescript

我试图找到一种在Rails中调试我的coffeescript的好方法.我的资产配置设置是:

# Do not compress assets
config.assets.compress = false
# Expands the lines which load the assets
config.assets.debug = true
Run Code Online (Sandbox Code Playgroud)

当我的coffeescript文件中有错误时,例如wepic.js.coffee.erb在执行rake assets:precompile任务后,我得到的唯一调试信息是错误类型和文件名:

rake aborted!
SyntaxError: unexpected TERMINATOR
(in /home/jtestard/projects/git/webdamsystem/app/assets/javascripts/wepic.js.coffee.erb)
Run Code Online (Sandbox Code Playgroud)

有时这还不足以快速发现错误,我试图通过行/列号获得更好的跟踪.有谁知道获得此类信息的方法?

abj*_*ror 3

如果您安装了 NPM/NodeJS(并且npm install coffee-script -g),您可以尝试编译coffee -c <filename>以查看行号。Textmate/Sublime 也有插件,您可以通过组合键查看 coffescript 文件的编译输出,但它们也需要安装 NodeJS/NPM。