Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
app
config
lib
.gitignore
Gemfile
README.rdoc
Rakefile
rails_kindeditor.gemspec

README.rdoc

Kindeditor4.0 for Rails3 (include 3.1 and 3.0.x)

Kindeditor for Rails3, including image and file upload using carrierwave.

Installation

Add this to your Gemfile

gem "carrierwave"
gem "rails_kindeditor"

Run “bundle” command.

bundle

Run install generator:

rails generate rails_kindeditor:install

That's all! By default, rails_kindeditor do not save upload file information into database.

Usage

Basically include <%= include_kindeditor_if_needed %> under the <head> element of your in your layout file:

<%= include_kindeditor_if_needed %>

In your controller, use include_kindeditor method to load kindeditor:

include_kindeditor
or
include_kindeditor :only => [:new, :edit]

Assign your textarea with id in your form:

:id => "kindeditor_id"

That's all.

Save upload file information into database(optional)

rails_kindeditor can save upload file information into database.

Just run migration generate, there are two ORM options for you: 1.active_record 2.mongoid, default is active_record.

rails generate rails_kindeditor:migration
or
rails generate rails_kindeditor:migration -o mongoid

The generator will copy model and migration to your application. When you are done, remember run rake db:migrate:

rake db:migrate

That's all.

Configuration options

You can load kindeditor javascript only in some action if you needed:

include_kindeditor :only => [:new, :edit]
include_kindeditor :except => [:index, :show, :destroy, :create]

You can config kindeditor by kindeditor-init.js file, please read Kindeditor's documents:

public/kindeditor/kindeditor-init.js [Rails3.1]
public/javascripts/kindeditor/kindeditor-init.js [Rails3.0.x]

License

MIT License. Copyright 2011

Kindeditor(4.x) for Rails3 中文文档

可供Rails3使用的gem, 包括了图片和附件上传功能,文件按照类型、日期进行存储。上传采用了Carrierwave。

安装

将下面代码加入Gemfile:

gem "carrierwave"
gem "rails_kindeditor"

运行“bundle”命令:

bundle

安装Kindeditor,运行下面的代码:

rails generate rails_kindeditor:install

完毕!默认情况下,rails_kindeditor在上传文件时不会把文件信息记录入数据库。

使用

在你的layout文件中的<head></head>内包含下面代码:

<%= include_kindeditor_if_needed %>

在你需要使用的controller里面,包含下面代码来控制加载javascript:

include_kindeditor
或者
include_kindeditor :only => [:new, :edit]

把需要转换的textarea赋予下列id值:

:id => "kindeditor_id"

完毕!

将上传文件信息记录入数据库(可选)

rails_kindeditor 可以将上传文件信息记录入数据库,以便扩展应用.

运行下面的代码,有两项选项:1.active_record 2.mongoid,默认是active_record。

rails generate rails_kindeditor:migration
or
rails generate rails_kindeditor:migration -o mongoid

运行下面的代码:

rake db:migrate

完毕!

配置选项(可选)

你可以有选择性地加载kindeditor的javascript:

include_kindeditor :only => [:new, :edit]
include_kindeditor :except => [:index, :show, :destroy, :create]

你可以通过修改kindeditor-init.js来配置kindeditor,详细配置方法可以阅读Kindeditor的文档:

public/kindeditor/kindeditor-init.js [Rails3.1]
public/javascripts/kindeditor/kindeditor-init.js [Rails3.0.x]

License

MIT License. Copyright 2011

Something went wrong with that request. Please try again.