您的位置:首页 > 编程语言 > Ruby

ruby -- 进阶学习(十三)解说ckeditor在production环境下如何完整显示

2013-09-07 00:13 417 查看
将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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: