2012-07-11 85 views
0

在顯示頁面上,我將字符串轉換成散列,TinyMCE的鋼軌3.1

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> 

但以下我的網頁,代碼不轉換

code not convert

回答

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> 

這適用於我。

+0

yupz,這工作,但我在顯示頁面的問題不是編輯器。 – 2012-07-11 08:26:18

+1

將@ page.content從<%= tinymce%>移至text_area_tag檢查我的答案,當您傳遞<%= tinymce%>時,會出現此錯誤,這是一個字符串參數,它需要一個哈希值的配置選項。 – PriteshJ 2012-07-11 08:32:49

+0

檢查我的問題,我編輯我的問題 – 2012-07-11 09:04:39

0

可選原料(@ page.content)也適用