Ckeditor gem issue with production mode

北慕城南 提交于 2019-12-05 22:31:55

问题


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.


回答1:


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



回答2:


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.




回答3:


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?




回答4:


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



来源:https://stackoverflow.com/questions/17636564/ckeditor-gem-issue-with-production-mode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!