Skip to content
ideadapt edited this page Oct 18, 2013 · 13 revisions

To use the CKEditor with Upload function, add Rails-CKEditor to your Gemfile (gem 'ckeditor') and follow Rails-CKEditor installation instructions.

You can configure more options of CKEditor "config.js" file following the Api Documentation .

RailsAdmin.config do |config|
  config.model Team do
    edit do
      # For RailsAdmin >= 0.5.0
      field :description, :ck_editor
      # For RailsAdmin < 0.5.0
      # field :description do
      #   ckeditor true
      # end
    end
  end
end

Although ckeditor is loaded in modal windows (e.g. twb), by default changes are not saved by submitting the modal. This is because the underlying textarea gets not updated before the ajax post request is issued. To prevent this you can use the following code:

$(document).ready ->
  $(document).on 'mousedown', '.save-action', (e) -> # triggers also when submitting form with enter
    for instance of CKEDITOR.instances
      editor = CKEDITOR.instances[instance]
      if editor.checkDirty()
        editor.updateElement();
    return true;

Add this code to assets/rails_admin/custom/ckeditor_ajax.js.coffee and create a file assets/rails_admin/custom/ui.js that loads this coffee file into asset pipeline:

//= require rails_admin/custom/ckeditor_ajax

At this time this only worked in dev env for me. Because in production the ui.js is not compiled into rails_admin assets by default ... And adding it to precompile did not help either ...

More here

Clone this wiki locally