Ace editor with rails 4 precompiled assets madness
Asked Answered
L

1

2

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?

Leapfrog answered 3/3, 2014 at 22:3 Comment(4)
Which version do you use? with latest version from ace-builds master, if i add mode-html.js to the end of ace.js, it doesn't look for other files.Tingly
Yes, I may be looking at a caching bug which would be really dumb on my part. I'll update after I find outLeapfrog
@AbeDadoun any luck with this? Posting your solution would be really helpful.Jene
Has anyone solved this problem? I am having the exact same issue!Sonia
F
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):

  • 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

Frig answered 8/9, 2014 at 20:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.