Ace编辑器与Rails 4预编译资产疯狂 [英] Ace editor with rails 4 precompiled assets madness
问题描述
我一直试图将Ace编辑器集成到Rails 4项目中,但无法使其在生产环境中正常工作。
I have been trying to integrate the Ace editor to a Rails 4 project and couldn't get it to work in production.
该编辑器可以渲染,但是-显然足够了,它无法加载mode- *文件。我试图将整个ace树添加到已编译资产中,希望它能以某种方式弄清楚它已经被加载,但是它仍在寻找 url / mode-html.js。
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".
有人用预编译的资产让Ace在Rails中工作吗?我是否缺少某些东西?
Has anyone had any luck making Ace work in Rails with precompiled assets? Am I missing something?
推荐答案
这是我使用的解决方法(在我的情况下适用于worker-*。js文件,但是它也应该适用于模式和主题):
This is the workaround I used (in my case for the worker-*.js files, but it should work for the modes and themes too):
- 在/ public中创建perm_assets / javascript
- 将.js文件(例如worker-json.js)复制到您自己的.js文件中的public / perm_assets / javascripts
- 中,添加以下行(在文档就绪块内) ):
ace.config.set( workerPath, / perm_assets / javascripts);
除了(或除了) workerPath之外,您还可以指定 modePath和 themePath。
Rather than (or in addition to) "workerPath", you can specify "modePath" and "themePath".
这次讨论也对我有所帮助: https://github.com。 com / ajaxorg / ace / issues / 655
I was helped by this discussion too: https://github.com/ajaxorg/ace/issues/655
这篇关于Ace编辑器与Rails 4预编译资产疯狂的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!