我有两个我使用和享受的宝石
宝石“activeadmin”和宝石“ckeditor”
我希望我的“内容”字段使用 ckeditor。
在我过去的应用程序中,我以如下形式呈现 ckeditor:
<%= form_for @resource do |f| %>
<div class="field">
<%= f.label :content %>
<br />
<%= cktext_area_tag("page_part[content]", @page_part.content) %>
</div>
...
<% end %>
现在我刚刚将 activeadmin 添加到我的堆栈中,并且喜欢我目前所看到的。所以,我读到您可以通过编辑 app/admin/#{resource}.rb 文件来自定义表单:
ActiveAdmin.register NewsItem do
form :html => { :enctype => "multipart/form-data" } do |f|
f.inputs "NewsItem", :multipart => true do
f.input :title
f.input :content
f.input :photo
#NOT WORKING
cktext_area_tag("news_item[content]", @news_item.content)
#NOT WORKING
end
f.buttons
end
end
我怎样才能让这个表单助手在 active_admin 中工作,我会用什么来代替 @news_item.content。@news_item 为空......所以现在我有点困惑。
当我尝试甚至没有像这样引用@news_item 时:
cktext_area_tag("news_item[content]", 'i cant be edited properly')
我仍然得到:
undefined method `cktext_area_tag' for #<ActiveAdmin::DSL:0x00000007e02250>
任何帮助,将不胜感激!