I'm using the CKEditor gem. My config for application.js
and routes.rb
are like the followings:
# application.js
//= require ckeditor/init
# routes.rb
mount Ckeditor::Engine => '/ckeditor'
The gem works fine in development mode, but when moving to the production mode, I got the error 404 when browsers request the js and css files in ckeditor folder:
GET http://mydomain/assets/ckeditor/config.js?t=D2LI 404 (Not Found)
GET http://mydomain/assets/ckeditor/skins/moono/editor.css?t=D2LI 404 (Not Found)
GET http://mydomain/assets/ckeditor/lang/vi.js?t=D2LI 404 (Not Found)
GET http://mydomain/assets/ckeditor/styles.js?t=D2LI 404 (Not Found)
Please help me to fix my ckeditor route config. Thank you in advance.
You'll need to explicitly direct Rails to precompile your CKEditor assets in production:
# config/application.rb
config.assets.precompile += Ckeditor.assets
Then, within your production environment, force a precompilation:
rake assets:precompile:all
In my case I was using Rails 4 and deploying to Heroku. I found I had to precompile the assets locally first, then commit the /public/assets/ckeditor
directory and deploy. Worked after that, although I don't really fancy this solution.
I had some trouble with only the lang files not being found in Rails 5.
I had to do this to get it working ->Rails.application.config.assets.precompile += %w(ckeditor/* ckeditor/lang/*)
in assets.rb
.
I don't know why the first declaration doesn't just include the lang folder in the first place (it works for the adapters, plugins, and skins folders). Bug maybe?
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