将CKEditor与Rails 3.1 Asset Pipline集成 [英] Integrating CKEditor with Rails 3.1 Asset Pipline

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

问题描述

我刚刚从Asset Rails 3.0迁移过来的Asset Pipeline。我试图让CKEditor进入管道,但所有的宝石,它是真的不清楚它们如何工作,并有很少或没有使用说明。

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 。我只是不知道从这里去哪里。此代码在开发中工作良好,但在生产中不工作。我在运行 rake assets:precompile 之前添加和提交到git,然后推送到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!

有一件事要注意如果您为webserver上的/ 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 Asset Pipline集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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