问题描述
我在我的 Rails 4 应用程序中使用了 ckeditor gem.一切都在本地和我的暂存 heroku 环境中运行良好,但在推动生产环境时出现此错误:
I'm using the ckeditor gem in my Rails 4 application.Everything works great locally and on my staging heroku environment, but I get this errors when pushing on the production environment :
GET http://myapp.herokuapp.com/assets/ckeditor/contents.css 404 (Not Found)
GET http://myapp.herokuapp.com/assets/ckeditor/skins/moono/icons.png 404 (Not Found)
编辑器显示良好,但缺少所有图标.
The editor shows up well, but all icons are missing.
我遵循了自述文件(https://github.com/galetahub/ckeditor),但是我可能遗漏了一些东西.
I followed the README (https://github.com/galetahub/ckeditor), but I'm probably missing something.
这是我的步骤:
1) Gem 安装、生成等...
1) Gem installation, generate etc ...
2) config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
在 application.js 中
2) config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
in application.js
3) mount Ckeditor::Engine =>/ckeditor"
在 routes.rb (我不明白为什么)
3) mount Ckeditor::Engine => "/ckeditor"
in routes.rb (I don't understand why)
4) 在 application.js 中
4) In application.js
//= require ckeditor/override
//= require ckeditor/init
这到底是做什么的,为什么需要覆盖?(这些文件在哪里,因为/app/assets
中没有,/lib/assets
中也没有,/vendor/assets
中也没有)
What is this doing exactly, why is override needed ? (Where are located these files, because there are not in /app/assets
, neither in /lib/assets
neither in /vendor/assets
)
Heroku 是只读的,因此我无法按照教程中的说明运行 rake 任务.我认为这就是我在生产模式下出现错误的原因.
Heroku is read only oriented, therefore I can't run the rake task as explained in the tutorial.And I think this is why I get the errors in production mode.
有人遇到过同样的问题吗?我解决了所有 stackoverflow 问题,但到目前为止都没有解决我的问题.
Did anyone faced the same problem ?I ran through all stackoverflow questions, but nothing resolved my problem so far.
更新:
我发现让它工作的唯一方法是实时编译:config.assets.compile = true
但我不想在生产中使用它,我不明白它为什么有效.
The only way I found out to make it works is the live compilation : config.assets.compile = true
But I would prefer not to use this in production, and I don't understand why it does work.
推荐答案
目前此问题的解决方案已更改.
Currently the solution for this problem has been changed.
不需要包含ckeditor/override.js"
There is no need to include "ckeditor/override.js"
1 更新您的 gem.
1 Update your gem.
bundle update ckeditor
2 将此行添加到您的文件 config/application.rb
2 Add this line to your file config/application.rb
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w( ckeditor/* )
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
它对我有用,希望对你也有用.
It works for me hope will work for you too.
这篇关于使用 Heroku 在生产 Rails 应用程序上运行 ckeditor 的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!