将 CKEditor 与 Rails 3.1 资产管道集成 [英] Integrating CKEditor with Rails 3.1 Asset Pipline

查看:33
本文介绍了将 CKEditor 与 Rails 3.1 资产管道集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Asset Pipeline 的新手,刚刚从 Rails 3.0 迁移过来.我正在尝试让 CKEditor 进入管道,但它的所有 gem 都不清楚它们是如何工作的,并且很少或没有使用说明.

I'm new to the Asset Pipeline, having just migrated over from Rails 3.0. I'm trying to get CKEditor into the pipeline, but all the gems for it are really unclear about how they work, and have little or no usage instructions.

我更愿意在不使用 gem 的情况下执行此操作,因为似乎我所要做的就是将源文件放入 vendor/assets 目录,然后将它们包含在 application 中.js.我已经尝试过,但是,当我预编译并推送到生产时,似乎找不到某些文件(例如,editor.css),并且编辑器没有完全显示(只是空白区域).

I would prefer to do this without using a gem, since it seems that all I have to do is drop the source files into the vendor/assets directory and then include them in application.js. I've tried that, however, when I precompile and push to production, it seems that some of the files aren't being found (editor.css, for example), and the editor doesn't show up at all (just blank area).

application.js

//= require jquery
//= require jquery_ujs
//= require ckeditor/ckeditor
//= require_self

这是vendor/assets/javascript/ckeditor/中的源文件,指向ckeditor.js.我只是不知道从哪里开始.此代码在开发中运行良好,但在生产中不起作用.我在添加和提交到 git 之前运行 rake assets:precompile,然后推送到 heroku.

That's with the source files in vendor/assets/javascript/ckeditor/, and is pointing to ckeditor.js. I'm just not sure where to go from here. This code works fine in development but does not work in production. I am running rake assets:precompile before adding and committing to git, and then pushing to heroku.

推荐答案

如果您使用的是 Rails 3.1.0,则应该升级到 3.1.1.在此版本中,预编译 rake 任务将资产编译为原始文件名和摘要文件名.这样,不知道管道感知的第三方代码仍然可以工作.

If you are on Rails 3.1.0, you should upgrade to 3.1.1. In this version the precompile rake task compiles assets into both original and digested filenames. This is so third-party code that is not pipeline aware will still work.

您需要将 ckeditor 目录及其所有子目录添加到预编译数组中,以便预编译任务知道要编译它们.

You will need to add the ckeditor directory and all its child directories to the precompile array so that the precompile task knows to compile them.

<代码>config.assets.precompile += your_files

your_files 可以是文件数组、正则表达式或 Procs - 捕获 ckeditor 文件名称所需的任何内容.我没有 ckeditor 来计算预编译中需要做的事情,所以如果你发布你想出的东西,其他人可能会很感激!

your_files can be an array of files, regexs or Procs - whatever is need to capture the names of the ckeditor files. I don't have ckeditor handy to work out what needs to go in precompile, so others might appreciate it if you post what you come up with!

需要注意的一件事是,如果您为网络服务器上的/assets 目录设置了未来的标头,则需要排除 CKeditor 目录.因为这些文件不会被指纹识别,所以当您更新 CKeditor 时可能会出现问题,因为某些客户端没有获得更新的代码,因为它们有一个标记为仅在未来某个时间过期的缓存副本.

One thing to watch is that if you have far-future headers set for the /assets directory on your webserver, you'll need to exclude the CKeditor directory. Because those files won't be fingerprinted, there may be issues when you update CKeditor with some clients not getting the updated code because they have a cached copy that marked to only expire some time in the future.

这篇关于将 CKEditor 与 Rails 3.1 资产管道集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆