Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ckeditor gem issue with production mode

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.

like image 456
VinhBS Avatar asked Jul 14 '13 04:07

VinhBS


3 Answers

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
like image 99
zeantsoi Avatar answered Oct 19 '22 05:10

zeantsoi


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.

like image 22
weimeng Avatar answered Oct 19 '22 05:10

weimeng


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?

like image 23
KcC0 Avatar answered Oct 19 '22 05:10

KcC0