【问题标题】:Ckeditor gem issue with production mode生产模式的 ckeditor gem 问题
【发布时间】:2016-07-24 22:41:23
【问题描述】:

我正在使用CKEditor gem。我对application.jsroutes.rb 的配置如下:

# application.js
//= require ckeditor/init

# routes.rb
mount Ckeditor::Engine => '/ckeditor'

gem 在开发模式下工作正常,但在进入生产模式时,当浏览器请求 ckeditor 文件夹中的 js 和 css 文件时出现错误 404:

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) 

请帮我修复我的 ckeditor 路由配置。提前谢谢你。

【问题讨论】:

    标签: ruby-on-rails ruby ckeditor


    【解决方案1】:

    您需要明确指示 Rails 在生产环境中预编译您的 CKEditor 资产:

    # config/application.rb
    config.assets.precompile += Ckeditor.assets
    

    然后,在您的生产环境中,强制进行预编译:

    rake assets:precompile:all
    

    【讨论】:

      【解决方案2】:

      就我而言,我使用的是 Rails 4 并部署到 Heroku。我发现我必须先在本地预编译资产,然后提交 /public/assets/ckeditor 目录并部署。在那之后工作,虽然我不太喜欢这个解决方案。

      【讨论】:

        【解决方案3】:

        我在 Rails 5 中找不到只有 lang 文件的问题。

        我必须这样做才能让它工作 ->Rails.application.config.assets.precompile += %w(ckeditor/* ckeditor/lang/*) in assets.rb

        我不知道为什么第一个声明首先不只包含 lang 文件夹(它适用于适配器、插件和皮肤文件夹)。也许是错误?

        【讨论】:

        • 你可以试试这个:Rails.application.config.assets.precompile += %w(ckeditor/**/*)
        【解决方案4】:

        如果您使用的是 Rails 4,只需将 ckeditor gem 升级到最新版本(~> 4.1.0)。

        在这里查看更多更新https://github.com/galetahub/ckeditor

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多