下载fckeditor插件 http://rubyforge.org/projects/fckeditorp/
解压放到工程插件目录下 vendor\plugins 并重命名为 fckeditor,命令行切到工程目录下然后运行 rake fckeditor:install,安装成功后
在自己的view层中添加
<%= javascript_include_tag :fckeditor %>
以及在你需要编辑的字段textarea替换为
<%= fckeditor_textarea(:book, :body, { :toolbarSet=> 'Simple', :width => '100%', :height => '400px' }) %>
:book为表名, :body为字段名, :toolbarSet为样式,可以在 fckcustom.js 文件里修改,后面是宽高啦
启动服务器,测试成功
如果出现这个错误 undefined method 'relative_url_root'
修改 vendor/plugins 下的 fckeditor 中的文件
app/controllers/fckeditor_controller.rb 和 lib/fckeditor.rb 一共两个文件每个文件有一处需要修改
1. 找到 uploaded = request.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}" 替换为
uploaded = ActionController::Base.relative_url_root.to_s+"#{UPLOADED}/#{params[:Type]}"
2. 找到 js_path = "#{request.relative_url_root}/javascripts" 替换为
js_path = "#{ActionController::Base.relative_url_root}/javascripts"