在Rails中使用FCKeditor插件實現WEB富文本編輯
環境:ubuntu linux 7.0.4? +? ruby 1.8.5 + Rails 1.2.3 + FCKeditor 0.4.1
直接從它的subversion庫里取得該Rails插件。先進入到你的項目根目錄,再執行如下命令
其他說明:
(1)你的linux必須先安裝了subversion。(ubuntu里用新立得搜subversion即得)
(2)把命令中的install 改為 destory,可以刪除安裝。
(3)我取到的是2007年4月份最后更新的, v 0.4.1版
(4)FCKeditor安裝在項目根目錄下的vendor/plugins/fckeditor 里,
(5)vendor/plugins/fckeditor里的README很值得一讀,我碰到Ajax問題,查了所以網上的中文資料都沒有提到,在這個README卻有。
用如下語句在頁面里含入它的javascript庫
在需要富文本的Form表單用如下語句生成一個富文件編輯框:
說明:topic對應模型對象,content對應它的字段。也就是要求當前頁要有@topic這個實例變量。
如果是用了ajax,則需要在form_remote_tag加上一個before項
??????????????????????:before?=>?fckeditor_before_js('topic',?'content'),
??????????????????????:url?=>?{:controller?=>?'topics',?:action?=>?'create',?:template?=>?'show'}?)%>
并且富文件編輯框要加一個ajax=true的選項:
在使上傳圖片的功能時碰到了錯誤。彈出出alert對話框,顯示:Error on file upload.Error number: 403
在日志里顯示如下,表面上看好象是路由配置的問題
ActionController::RoutingError (no route found to match "/fckblank.html" with {:method=>:get}):
/var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1292:in `recognize_path'
/var/lib/gems/1.8/gems/actionpack-1.13.3/lib/action_controller/routing.rb:1282:in `recognize'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/dispatcher.rb:40:in `dispatch'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:113:in `handle_dispatch'
/var/lib/gems/1.8/gems/rails-1.2.3/lib/webrick_server.rb:79:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
/usr/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
/usr/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start'
/usr/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
最后在http://blog.caronsoftware.com/articles/2006/12/03/fckeditor-0-4-0-released#comment-1745找到了答案,這是一個BUG
解決方法 :
修改:vendor/plugins/fckeditor/app/controller/fckeditor_controller.rb
將原來的
改為
posted on 2007-08-25 16:44 陳剛 閱讀(2355) 評論(2) 編輯 收藏 所屬分類: Rails&Ruby