I have been trying to integrate the Ace editor to a Rails 4 project and couldn't get it to work in production.
我一直在尝试将Ace编辑器集成到Rails 4项目中,但却无法在生产中使用它。
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".
编辑器渲染但显然足够,它无法加载mode- *文件。我试图将整个ace树添加到已编译的资产中,希望它能以某种方式弄清楚它已经被加载,但它仍然在寻找“url / mode-html.js”。
Has anyone had any luck making Ace work in Rails with precompiled assets? Am I missing something?
有没有人有幸在使用预编译资产在Rails中使用Ace工作?我错过了什么吗?
1 个解决方案
#1
0
This is the workaround I used (in my case for the worker-*.js files, but it should work for the modes and themes too):
这是我使用的解决方法(在我的情况下为worker - * .js文件,但它也适用于模式和主题):
- 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):
在/ public中创建perm_assets / javascripts
将.js文件(例如worker-json.js)复制到public / perm_assets / javascripts
在您自己的.js文件中,添加以下行(在文档就绪块内):
ace.config.set("workerPath", "/perm_assets/javascripts");
Rather than (or in addition to) "workerPath", you can specify "modePath" and "themePath".
您可以指定“modePath”和“themePath”,而不是(或者除了)“workerPath”。
I was helped by this discussion too: https://github.com/ajaxorg/ace/issues/655
我也得到了这个讨论的帮助:https://github.com/ajaxorg/ace/issues/655
#1
0
This is the workaround I used (in my case for the worker-*.js files, but it should work for the modes and themes too):
这是我使用的解决方法(在我的情况下为worker - * .js文件,但它也适用于模式和主题):
- 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):
在/ public中创建perm_assets / javascripts
将.js文件(例如worker-json.js)复制到public / perm_assets / javascripts
在您自己的.js文件中,添加以下行(在文档就绪块内):
ace.config.set("workerPath", "/perm_assets/javascripts");
Rather than (or in addition to) "workerPath", you can specify "modePath" and "themePath".
您可以指定“modePath”和“themePath”,而不是(或者除了)“workerPath”。
I was helped by this discussion too: https://github.com/ajaxorg/ace/issues/655
我也得到了这个讨论的帮助:https://github.com/ajaxorg/ace/issues/655