Rails3安装ckeditor
在项目Gemfile中增加一下代码:
gem 'ckeditor', '3.5.4'
#安装插件
bundle install
#生成ckeditor的js文件,查看config/initializers/ckeditor.rb
#获取更多的配置信息
rails generate ckeditor:base
#生成上传图片的类
#For attachment_fu:
rails generate ckeditor:migration --backend=attachment_fu
#For paperclip:
rails generate ckeditor:migration --backend=paperclip
#执行migration,生成数据库表
rake db:migrate
#在application.rb增加以下内容
config.autoload_paths += %W( #{config.root}/app/models/ckeditor )
#引用js文件
<%= javascript_include_tag :ckeditor %>
#创建输入框的普通helper方法
<%= ckeditor_textarea("object", "field", :width => '100%', :height => '200px') %>
默认的ckeditor配置文件如下:
public/javascripts/ckeditor/config.js
默认的ckeditor样式文件如下:
public/javascripts/ckeditor/contents.css