使用带有rails嵌套属性的ckeditor gem

时间:2012-03-10 01:45:48

标签: ruby-on-rails ckeditor nested-forms nested-attributes formbuilder

是否有人能够以嵌套形式使用附加到表单构建器对象的ckeditor gem(https://github.com/galetahub/ckeditor/issues/98)?

的Gemfile:

gem 'rails', '3.2.1'
....
gem "nested_form"
gem "ckeditor", "3.7.0.rc3"

我将问题提取到一个非常简单的嵌套表单应用程序,即

post.rb:

has_many :comments
accepts_nested_attributes_for :comments

所以我尝试使用ckeditor来编辑评论。视图如下所示:

<%= nested_form_for(@post) do |f| %>

<%= f.label :post_content %>

<%= f.text_area :post_content %>
<%= f.fields_for :comments do |cf| %>
<%= cf.cktext_area :comment_content %>
<% end %>
....

评论内容会显示正常文本区域。如果我将表单的帖子部分中的“f.text_area”切换为“f.cktext_area”,则会显示帖子内容的ckeditor。

呈现表单时,日志中不会出现任何错误。

我错过了什么吗?

1 个答案:

答案 0 :(得分:1)

你用:

生成ckeditor文件吗?
rails generate ckeditor:models --orm=active_record --backend=paperclip