0

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

rails_id
  • 8,120
  • 4
  • 46
  • 84

2 Answers2

1

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.

Pritesh Jain
  • 9,106
  • 4
  • 37
  • 51
  • 1
    shift the @page.content from <%= tinymce %> to text_area_tag check my answer, this error occurs when you pass <%= tinymce %> ,a string argument it needs a Hash of configuraion options here. – Pritesh Jain Jul 11 '12 at 08:32
  • @anonymousxxx, Use html_safe helper to convert the string content to html display. check updated answer – Pritesh Jain Jul 11 '12 at 10:29
0

Optionally raw(@page.content) also works

Moin Haidar
  • 1,654
  • 1
  • 16
  • 16