Ruby on rails 3.1 TinyMCE适用于轨道3.1

Ruby on rails 3.1 TinyMCE适用于轨道3.1,ruby-on-rails-3.1,tinymce,static-pages,Ruby On Rails 3.1,Tinymce,Static Pages,在显示页面中,我将字符串转换为哈希 form.html.erb <%= f.text_area :content, :rows => 20, :cols => 120 %> <script type="text/javascript"> $(function() { $('textarea').tinymce({ theme: 'advanced' }); }); </script> 20,:cols=>120%> $(函数(){ $('t

在显示页面中,我将字符串转换为哈希

form.html.erb

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

<script type="text/javascript">
$(function() {
$('textarea').tinymce({
  theme: 'advanced'
});
});
</script>
20,:cols=>120%>
$(函数(){
$('textarea').tinymce({
主题:“高级”
});
});
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>

“阿布顿”%>| “你确定吗?”,:method=>:delete%>|

但我的页面如下,代码不转换


我没有使用tinymce,但根据文档,我了解的是

如果要向编辑器添加内容,请将其传递到文本区域

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

# you can pass configuration option to tinymce here
<%= tinymce %>
“tinymce”,:rows=>40,:cols=>120%>
#您可以在此处将配置选项传递给tinymce
在显示页面中

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

#应用html_safe函数将字符串解释为html


这对我有效。

可选的原始(@page.content)也有效。

将@page.content从转换为text\u area\u标记检查我的答案,当您传递字符串参数时会发生此错误,它需要配置选项的散列。@anonymousxxx,使用html\u安全帮助程序将字符串内容转换为html显示。检查更新的答案