Ace editor with rails 4 precompiled assets madness

痞子三分冷 提交于 2019-12-10 23:47:02

问题


I have been trying to integrate the Ace editor to a Rails 4 project and couldn't get it to work in production.

The editor renders but -obviously enough, it can't load the mode-* files. I tried to add the whole ace tree to the compiled assets hoping it would somehow figure out it's already loaded, but it's still looking for "url/mode-html.js".

Has anyone had any luck making Ace work in Rails with precompiled assets? Am I missing something?


回答1:


This is the workaround I used (in my case for the worker-*.js files, but it should work for the modes and themes too):

  • create perm_assets/javascripts in /public
  • copy the .js files (e.g. worker-json.js) to public/perm_assets/javascripts
  • in one of your own .js files, add the following line (inside a document ready block):

ace.config.set("workerPath", "/perm_assets/javascripts");

Rather than (or in addition to) "workerPath", you can specify "modePath" and "themePath".

I was helped by this discussion too: https://github.com/ajaxorg/ace/issues/655



来源:https://stackoverflow.com/questions/22158464/ace-editor-with-rails-4-precompiled-assets-madness

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!