在ROR

2011-12-07 44 views
0

我想用我的配置CKEditor的在我的RoR應用程序使用CKEDITOR,在ROR

我已經下載了我的CKEditor從

http://ckeditor.com/download (.tar.gz) 

,然後通過編輯ckeditor.pack其配置(僅添加那些插件,我需要) 然後使用命令編譯它:

java -jar ckpackager.jar ckeditor.pack 

然後我檢查了運行我的CKEditor和它完美的罰款。

然後在這個帖子給出:

http://ferric.net/articles/2009/09/07/ckeditor-3-0-and-rails/ 

我複製我的CKEditor目錄RAILS_ROOT /公/ JavaScript和編輯我的RAILS_ROOT /應用/視圖/佈局/ application.html.erb文件:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Reader</title> 
    <%= stylesheet_link_tag "application" %> 
    <%= javascript_include_tag "application" %> 
    <%= javascript_include_tag 'ckeditor/ckeditor.js' %> 
    <%= csrf_meta_tags %> 
<script type="text/javascript"> 
    $(function() { 
    if ($('textarea').length > 0) 
    {  
     var data = $('textarea'); 
     $.each(data, function(i) 
     { 
     CKEDITOR.replace(data[i].id); 
     } 
     );  
    } 
    }); 
</script> 

</head> 
<body> 

<%= yield %> 

</body> 
</html> 

但是,當我試圖運行我的看法,那就是:

<h2> Write your article</h2> 
<p> 
<textarea >Test Text</textarea> 
</p> 

我得到一個簡單的文本區域,而不是C keditor。

當我試圖找出它說的原因:

Request URL:http://localhost:3000/assets/ckeditor/ckeditor.js 
Request Method:GET 
Status Code:404 Not Found 

是什麼,是我做錯了,我怎麼可以用我在ROR CKEditor的?

回答

2

我複製我的CKEditor到RAILS_ROOT /公/ JavaScript的制定出這個問題/然後編輯我的意見/佈局/ application.html.erb來補充一點:

<%= javascript_include_tag "/javascripts/ckeditor/ckeditor.js" %> 

頭終於使它:

<!DOCTYPE html> 
<html> 
<head> 
    <title>Reader</title> 
    <%= stylesheet_link_tag "application" %> 
    <%= javascript_include_tag "application" %> 
    <%= javascript_include_tag "/javascripts/ckeditor/ckeditor.js" %> 
    <%= csrf_meta_tags %> 
</head> 
<body> 

<%= yield %> 

</body> 
</html> 

它使用

<textarea class="ckeditor" id="editor1" name="editor1" >Test Text</textarea> 
0

假設你使用Rails 3.1,你必須把你的資產放到「app-> assets」文件夾中。 Rails 3.1引入了一種名爲「資產管道」的新概念,它基本上抓住了您的所有資產並對它們進行了組合/優化。你可以在這裏讀了它:http://guides.rubyonrails.org/asset_pipeline.html

但是你沒有手動安裝的話,你可以用這個寶石:https://github.com/galetahub/ckeditor

+0

我手工安裝它,因爲我已經配置它按我使用的工作,我一直在我的C​​KEditor目錄中的文件夾入資產,但我仍然得到404。任何幫助? – d34th4ck3r

+0

你能上傳你的ckeditor文件夾嗎?稍後我可以自己看看... –