什麼是FckEditor, 請看這裡
1. 下載FckEditor的Rails外掛, 在這裡 目前的版本是0.51
2. 將解壓縮的資料夾放到你的專案的vendor\plugins資料夾中,將目錄名改成fckeditor
3. 然後進入指令模式,進入到專案的目錄中,按下以下指令:
rake fckeditor:install
4. 安裝完成後請檢查目錄vendor/plugins下是否有fckeditor所安裝的檔案,如果有表示安裝成功
5. 因為fckeditor主要是由javascript組成,所以到準備掛上fckeditor的頁面下,通常是layout的<head></head>中,放入以下:
<%= javascript_include_tag :fckeditor %>
6. 然後在想要放置的view中,用fckeditor來替代原本的<%= text_area(:object, :method) %>功能,object當然是資料表,method就是欄位名,要記得在這個action中做一個object出來
7. fckeditor的替代方式就是用以下方法:
<%= fckeditor_textarea(:object, :method, { :toolbarSet => 'Simple', :width => '100%;', :height => '200px' }) %> 模式,寬度與高度可以在此調整
8. 接下來重新啟動server,再到放置fckeditor的頁面
9. 開啟後可能會看到這個錯誤訊息:undefined method 'relative_url_root',如果有,請參考第10
10. 修改vendor/plugins下的fckeditor中的檔案,共有兩處需要修改:一. app/controllers/fckeditor_controller.rb 還有 二. lib/fckeditor.rb
一. 找到 uploaded = request.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}" 然後用
uploaded = ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}" 替換
二. 找到 js_path = "#{request.relative_url_root}/javascripts" 然後用
js_path = "#{ActionController::Base.relative_url_root}/javascripts" 替換
三. 別搞錯檔案
11. 然後重新啟動伺服器看看,這時候就可以看到可愛的fckeditor而不是傳統的textarea了...
- Jan 18 Mon 2010 23:22
在2.3版的Rails上安裝FckEditor
close
全站熱搜
留言列表
發表留言