VinhBS
VinhBS

Reputation: 677

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.

Upvotes: 8

Views: 5421

Answers (4)

KcC0
KcC0

Reputation: 363

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?

Upvotes: 2

Kumaresan Chinnaraj
Kumaresan Chinnaraj

Reputation: 76

Just upgrade the ckeditor gem to latest version(~> 4.1.0) in case if you are using Rails 4.

check more update here https://github.com/galetahub/ckeditor

Upvotes: 1

weimeng
weimeng

Reputation: 351

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.

Upvotes: 2

zeantsoi
zeantsoi

Reputation: 26193

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

Upvotes: 9

Related Questions