0

ショーページで、文字列をハッシュに変換し、

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>

しかし、私のページは次のとおりで、コードは変換されません

コードは変換されません

4

2 に答える 2

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>

これは私にとってはうまくいきます。

于 2012-07-11T08:16:49.740 に答える
0

オプションで raw(@page.content) も機能します

于 2013-05-12T08:52:01.287 に答える