zoukankan      html  css  js  c++  java
  • ruby -- 进阶学习(十三)解说ckeditor在production环境下如何完整显示

    将ROR项目从development环境改为production环境时,运行rake assets:precompile后,

    ckeditor的界面就无法完整显示?! @_@??

    出现 ActionController::RoutingError (No route matches [GET] "/assets/ckeditor/config.js")

    solution :creating a rake task that couples with "assets:precompile" to create "non-digested" versions of the ckeditor asset files after pushing to production,and made a /lib/tasks/ckeditor.rake file with the following task.

    就是说在 /lib/tasks目录下创建个新的文件ckeditor.rake,在该文件中添加下面代码:

    # lib/tasks/ckeditor.rake
    require 'fileutils'
    desc "Create nondigest versions of all ckeditor digest assets"
    task "assets:precompile" do
      fingerprint = /-[0-9a-f]{32}./
      for file in Dir["public/assets/ckeditor/**/*"]
        next unless file =~ fingerprint
        nondigest = file.sub fingerprint, '.'
        FileUtils.cp file, nondigest, verbose: true
      end
    end

    然后在 /config/application.rb中添加下面代码:

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

    接着在 /app/assets/javascripts/application.js中添加:

    //= require ckeditor/ckeditor

    在 /config/route.rb 中,

    mount Ckeditor::Engine => '/ckeditor'

     重新运行 rake assets:precompile

     这样ckeditor的界面就能完整显示啦!!

     @_@!! over~~

     附:参考链接:https://github.com/galetahub/ckeditor/issues/307

  • 相关阅读:
    算法导论————KMP
    KMP算法
    几个很好的OJ网站
    查找(二分、hash、桶)
    动态规划
    贪心(未完待续)
    搜索的题
    codeVS 1031 质数环
    《将博客搬至CSDN》
    HDU1717小数化分数2
  • 原文地址:https://www.cnblogs.com/lmei/p/3306643.html
Copyright © 2011-2022 走看看