rails_id
rails_id

Reputation: 8220

TinyMCE for rails 3.1

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

Upvotes: 0

Views: 485

Answers (2)

Moin Haidar
Moin Haidar

Reputation: 1694

Optionally raw(@page.content) also works

Upvotes: 0

Pritesh Jain
Pritesh Jain

Reputation: 9146

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.

Upvotes: 1

Related Questions