CKEditor文本区域在rails 3.1应用程序中为空 [英] CKEditor text area is blank in rails 3.1 app

查看:162
本文介绍了CKEditor文本区域在rails 3.1应用程序中为空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图嵌入一个ckeditor到一个窗体,它只是空白。文本区域只是一个空格,我希望找到一个html编辑器窗口。我有一个模型,我想描述字段是html文本。我认为这将是方便的使用ckeditor编辑它。我不能解决为什么文本字段编辑器不显示。

I'm trying to embedd a ckeditor into a form and it just comes up blank. The text area is just an empty space where I expect to find an html editor window. I have a model where I want the "description" field to be html text. I thought it would be convenient to use ckeditor to edit it. I can't work out why the text field editor is not showing.

我有一个rails 3.1应用程序,我使用ckeditor宝石.2)。我已下载ckeditor并将其放在我的assets / javascripts文件夹中。

I've got a rails 3.1 app, and I'm using the ckeditor gem (version 3.6.2). I've downloaded ckeditor and put it in my assets/javascripts folder.

在我的application.html.erb文件中,我有这一行:

In my application.html.erb file I have this line:

<%= javascript_include_tag "ckeditor/ckeditor.js" %>

在我看来,我有一些代码:

In my view I have some code like this:

<%= form_for(@k) do |f| %>
<%= f.cktext_area :description, :toolbar => 'Full', :width => 800, :height => 400 %>

这样生成html:

<textarea id="k_description" rows="20" name="k[description]" cols="40"  style="visibility: hidden;"></textarea>
<script type="text/javascript">
//<![CDATA[
if (CKEDITOR.instances['k_description']) {CKEDITOR.remove(CKEDITOR.instances['k_description']);}CKEDITOR.replace('k_description', { height: 400,language: 'en',toolbar: 'Full',width: 800 });
//]]>
</script>

这一切看起来都应该工作,但不是。

It all looks like it should work, but it doesn't. What am I missing?

推荐答案

由于CKeditor链接其依赖关系的方式,您必须将其移动到公用文件夹。有一个帮助选项进入Rails 3.1.1,我相信会解决这个问题。 (:digest => false)。

Because of the way CKeditor links its dependancies you'll have to move it to the public folder. There is a helper option coming in Rails 3.1.1 which I believe will fix this problem. (:digest => false).

这篇关于CKEditor文本区域在rails 3.1应用程序中为空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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