Question

in show page, i will convert string into hash,

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>

but my page following, code not convert

code not convert

Was it helpful?

Solution

I have not used tinymce , but as per documentation what I understand is

If you want to add content to editor pass that to the text area

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

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

In Show page

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

This works for me.

OTHER TIPS

Optionally raw(@page.content) also works

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top