使用Heroku在生产Rails应用程序上运行ckeditor的问题

Jér*_*Boé 18 heroku production-environment ckeditor asset-pipeline ruby-on-rails-4

我在我的Rails 4应用程序中使用ckeditor gem .在本地和我的stoku heroku环境中,一切都很好用,但是在推动生产环境时我遇到了这个错误:

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)
Run Code Online (Sandbox Code Playgroud)

编辑器显示良好,但缺少所有图标.

我按照自述文件(https://github.com/galetahub/ckeditor),但我可能错过了一些东西.

这是我的步骤:

1)宝石安装,生成等......

2)config.autoload_paths += %W(#{config.root}/app/models/ckeditor)在application.js中

3)mount Ckeditor::Engine => "/ckeditor"在routes.rb(我不明白为什么)

4)在application.js中

//= require ckeditor/override
//= require ckeditor/init
Run Code Online (Sandbox Code Playgroud)

这究竟是做什么的,为什么需要覆盖呢?(这些文件位于何处,因为没有/app/assets,但/lib/assets两者都没有/vendor/assets)

Heroku是只读的,因此我不能像教程中所解释的那样运行rake任务.我认为这就是我在生产模式中得到错误的原因.

有人遇到过同样的问题吗?我浏览了所有stackoverflow问题,但到目前为止还没有解决我的问题.

更新:

我发现让它工作的唯一方法是实时编译:config.assets.compile = true 但我不想在生产中使用它,我不明白它为什么会起作用.

swi*_*osz 15

目前,此问题的解决方案已更改.

没有必要包含"ckeditor/override.js"

1更新你的宝石.

bundle update ckeditor
Run Code Online (Sandbox Code Playgroud)

2将此行添加到文件config/application.rb中

config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w( ckeditor/* )
config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
Run Code Online (Sandbox Code Playgroud)

它对我有用希望对你也有用.


小智 5

我刚刚解决了这个问题:https://github.com/galetahub/ckeditor/issues/307#issuecomment-22186377.

基本上,您将ckeditor资产添加到预编译列表中application.rb,使用rake任务在部署期间将它们复制到正确的位置.

希望能帮助到你.


小智 1

添加config.assets.precompile += Ckeditor.assetsapplication.rb应该做的工作。

  • 即使在运行第二个“rake asset:precompile”之后,它也不会改变任何东西 (2认同)