I'm trying to use CKEditor in a Rails 3.1 app. I have the ckeditor directory in app/assets/javascripts/ckeditor/, with extraneous stuff like the uncompressed and modularized source removed.
It works fine in development. In production or staging environments, ckeditor can't find it's own files: config.js, lang/en.js skins/kama/editor.css. I can see that these files are not being precompiled, which makes sense since the asset pipeline by default won't include or precompile anything that matches /.css/ or /.js/.
According to the rails docs and previous answers like this one, adding the files I need to config.assets.precompile is supposed to be the solution. However, despite extensive effort I cannot figure out what format I am supposed to use with config.assets.precompile. It's not documented and no examples are given.
I've tried explicitly adding the files by name:
config.assets.precompile << ['config.js', 'en.js', 'editor.css']
I've tried adding regexes that will match the files:
config.assets.precompile << [ /.*config\.js/, /.*en.js/, /.*editor.css/ ]
I've tried explicitly adding the full paths:
config.assets.precompile << File.join(Rails.root, 'app', 'assets', 'javascripts', 'ckeditor', 'config.js')
(etc...)
In all of these cases (and everything else I've tried), running rake assets:precompile still fails to move the files I need into public/assets. All the images and such go, but not the three javascript and/or css files CKEditor needs to run.
Any thoughts?
I've run into similar issues. I ended up using CKEditor without asset pipeline :)
After several gems tried, none worked ok in production environment. I ended up putting ckeditor into public
folder of the app. That skips the asset pipeline process completely and ckeditor works just fine in production as well. No assets pre-compilation though...
Using rails 3.1, CKEditor 4.1. Although this is an old thread, maybe this could help someone...
Update: Also, if you're testing on your local production environment, don't forget to set serve_static_assets
to true in config/environments/production.rb
For me it was fixed by overriding default precompile task (I used Rails 4 and CkEditor 4).
config.assets.precompile += ['ckeditor/*']
//= require ckeditor/init
lib/tasks/precompile_hook.rake
and paste text from this answer Precompile hook If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With