如何在Rails 3.1(gem + Asset Pipeline)中配置CKEditor [英] How to configure CKEditor in Rails 3.1 (gem + Asset Pipeline)
问题描述
我已经从 https://github.com/galetahub/ckeditor 成功配置了ckeditor gem.在我的Rails 3.1应用程序上.我现在的问题是我不知道如何配置CKEditor.在启用资产管道的Rails 3.1应用程序中,根据自述文件使用的文件根本不存在.
I've successfully configured the ckeditor gem from https://github.com/galetahub/ckeditor on my Rails 3.1 app. My problem now is that I can't figure out how to configure the CKEditor. The files that are used according to the Readme simply don't exists in a Rails 3.1 application with the asset pipeline enabled.
推荐答案
一旦我弄清抛出的错误消息,答案就很容易.
The answer was easy once i've figured out the thrown error message.
/app/assets/javascript/ckeditor
CKEDITOR.editorConfig = function( config )
{
config.toolbar_MyToolbar =
[
{ name: 'document', items : [ 'NewPage','Preview' ] },
{ name: 'clipboard', items : [ 'Cut','Copy','Paste','PasteText','PasteFromWord','-','Undo','Redo' ] },
{ name: 'editing', items : [ 'Find','Replace','-','SelectAll','-','Scayt' ] },
{ name: 'insert', items : [ 'Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'
,'Iframe' ] },
'/',
{ name: 'styles', items : [ 'Styles','Format' ] },
{ name: 'basicstyles', items : [ 'Bold','Italic','Strike','-','RemoveFormat' ] },
{ name: 'paragraph', items : [ 'NumberedList','BulletedList','-','Outdent','Indent','-','Blockquote' ] },
{ name: 'links', items : [ 'Link','Unlink','Anchor' ] },
{ name: 'tools', items : [ 'Maximize','-','About' ] }
];
}
这是重要的部分,在对ckeditor的需求之后 之后放置require_tree(包括ckeditor/config.js): /app/assets/javascript/application.js
This is the important part, place the require_tree (which includes the ckeditor/config.js) after the require for ckeditor: /app/assets/javascript/application.js
//= require jquery
//= require jquery_ujs
//= require ckeditor/ckeditor
//= require_tree .
这篇关于如何在Rails 3.1(gem + Asset Pipeline)中配置CKEditor的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!