1、安装rails的FCKeditor插件
script/plugin install
svn://rubyforge.org/var/svn/fckeditorp/trunk/fckeditor
如果出现下面的错误:
A D:\open_rails\mephisto\trunk\vendor\plugins\fckeditor\public\javascripts\fckeditor\htaccess.txt
Exported revision 41.
wget http://cnruby.googlecode.com/svn/trunk/rails-projects/fckeditor_use/public/javascripts/fckcustom.js
A D:\open_rails\mephisto\trunk\vendor\plugins\fckeditor\public\javascripts\fckeditor\htaccess.txt
Exported revision 41.
Plugin not found: ["svn://rubyforge.org/var/svn/fckeditorp/trunk/fckeditor"]
那么你要使用下面命令来完成安装:wget http://cnruby.googlecode.com/svn/trunk/rails-projects/fckeditor_use/public/javascripts/fckcustom.js
mv fckcustom.js public/javascripts/.svn co http://cnruby.googlecode.com/svn/trunk/rails-projects/fckeditor_use/public/javascripts/fckeditor/ public/javascripts/fckeditor
或者,直接去rubyforge.org下载安装包,到vender/plugin中,用rake fckeditor:install安装
2、使用:
1)非AJAX方式:非常简单,首先你需要从你的action传来一个对象,如果没有你就会一直收到一个nil错误。假设为@task=Task.new,artical有一个content字段用来存储文章内容
然后在页面调用:
0.4.1以下版本中有个小bug,在上传图片时的bug.请用附件覆盖原来的controller
bug: gif图片(jpeg也有可能)很小时,controller中的check_file方法中得到的file.class为StringIO类型。默认配置会导致上传失败,修改成即可(原因尚不明):
ruby 代码
- def check_file(file)
- # check that the file is a tempfile object
- unless "#{file.class}" == "Tempfile" or "#{file.class}"=="StringIO"
- @errorNumber = 403
- throw Exception.new
- end
- file
- end