开发者

How to install 'Ckeditor' for 'Active Admin' with 'Rails 3.1'

I looking for how to install Ckeditor for Active_Admin

I already installed Ckeditor and I have put this line in my 'initializers/active_admin.rb' file.

# To load a javascript file:

config.register_javascript 'ckeditor/config.js'

And the line

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)

in my 'config/application.rb'

In the begining the 'config.js' 开发者_高级运维file wasn't loaded because when I install Ckeditor gem it creates a folder named Ckeditor in public/javascripts but with rails 3.1, I had to move this folder into assets/javascripts...

That's what I've done.

Now the file "config.js' is loaded.

But now I don't know what I have to do next


Rails 3.2

activeadmin-0.4.3

in 'initializers/active_admin.rb' file.

  config.register_javascript 'ckeditor/ckeditor.js' 
  config.register_javascript 'ckeditor/init.js'

in form

 = f.cktext_area :text


If your're using the assets pipeline with external host server you have to hack a little bit.

Your assets/javascripts/active_admin.js should look like this:

//= require active_admin/base
//= require_self
//= require ckeditor/ckeditor
//= require ckeditor/init

var CKEDITOR_BASEPATH = 'http://assets.yourdomain.com/assets/ckeditor/';

Then you're good to go.


Add

var CKEDITOR_BASEPATH = '/assets/ckeditor/';

to the start of your ckeditor.js file.

I believe you are having an issue with the new location of the files in rails 3.1. Make sure all your ckeditor files are located in the javascript/ckeditor folder (or modify the link accordingly).

See http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path


You can also use in your forms

f.input :name, :as => :ckeditor


There is a page in the oficial wiki for this task.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜