2012-07-11 87 views
0

在显示页面上,我将字符串转换成散列,TinyMCE的钢轨3.1

form.html.erb

<%= f.text_area :content, :rows => 20, :cols => 120 %> 

<script type="text/javascript"> 
$(function() { 
$('textarea').tinymce({ 
    theme: 'advanced' 
}); 
}); 
</script> 

show.html.erb

<p> 
<%= @page.content %> 
</p> 
<p> 
<%= link_to "Edit", editcontent_path(@page), :class => "abutton" %> | 
<%= link_to "Destroy", destroycontent_path(@page), :confirm => 'Are you sure?', :method => :delete %> | 
<%= link_to "View All", admins_view_content_path %> 
</p> 

但以下我的网页,代码不转换

code not convert

回答

1

我没有使用TinyMCE的,但按照文档我的理解是

如果你想将内容添加到编辑器传递到文本区域

<%= text_area_tag :editor, @page.content , :class => "tinymce", :rows => 40, :cols => 120 %> 

# you can pass configuration option to tinymce here 
<%= tinymce %> 

在显示页面

<p> 
<%= @page.content.html_safe %> #Apply html_safe function to interpret string as html 
</p> 

这适用于我。

+0

yupz,这工作,但我在显示页面的问题不是编辑器。 – 2012-07-11 08:26:18

+1

将@ page.content从<%= tinymce%>移至text_area_tag检查我的答案,当您传递<%= tinymce%>时,会出现此错误,这是一个字符串参数,它需要一个哈希值的配置选项。 – PriteshJ 2012-07-11 08:32:49

+0

检查我的问题,我编辑我的问题 – 2012-07-11 09:04:39

0

可选原料(@ page.content)也适用