Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrating CKEditor with Rails 3.2

Similar to Integrating CKEditor with Rails 3.1 Asset Pipline

I am trying to integrate ckeditor with my rails 3.2 application.

I have all ckeditor files copied under /app/assets/javascripts/ckeditor/*.

I have the following lines in my application.js and application.js is included in my layout file:

//= require jquery
//= require jquery_ujs
//= require ckeditor/ckeditor
//= require_self

Taken it from the answer to Integrating CKEditor with Rails 3.1 Asset Pipline

I can understand that I need to add something like:

config.assets.precompile += your_files

to my development.rb file so that all the ckeditor files are precompiled when the application is loaded.

Although I tried a couple of paths, non worked and I keep getting the following error:

error on page view and the text area is not shown at all

Can someone please tell me the right regular expresion to include all files for precompile, please?

like image 816
Farnaz Avatar asked Mar 14 '12 01:03

Farnaz


4 Answers

I encountered the same problem and found a solution.Go to the following Link: http://docs.cksource.com/CKEditor_3.x/Developers_Guide/Specifying_the_Editor_Path

<script type="text/javascript">
var CKEDITOR_BASEPATH = '/assets/ckeditor/';
</script>
<%= javascript_include_tag "application" %>

you don't need to set config.assets.precompile anything.

like image 98
selbergzeta Avatar answered Oct 14 '22 09:10

selbergzeta


rails 3.2 fix:

  1. in assets/javascripts/application.js
    ... blablabla ...
    //= require ckeditor_fix        #- add this line
    //= require ckeditor/init
    //= require_tree .
  2. in assets/javascripts create new file ckeditor_fix.js
    var CKEDITOR_BASEPATH = '/assets/ckeditor/';
like image 44
kaboo Avatar answered Oct 14 '22 09:10

kaboo


I used this guide to add ckeditor to activeadmin in Rails 3.2 with the asset pipeline enabled: https://github.com/gregbell/active_admin/wiki/CKEditor-integration

It worked like a charm.

The only additional thing I did was add this line to my environment:

config.assets.precompile += ['active_admin.css', 'active_admin.js', 'ckeditor/init.js']
like image 2
Dave Christiansen Avatar answered Oct 14 '22 10:10

Dave Christiansen


Note that many of these answers refer to the ckeditor gem ( https://github.com/galetahub/ckeditor/ ), not just the ckeditor project ( http://ckeditor.com ) especially where you see reference to the ckeditor/init.js file.

There are other gems for ckeditor integration, including ckeditor-rails ( https://github.com/tsechingho/ckeditor-rails ) which is a lighter weight, simpler solution.

See also Integrating CKEditor with Rails 3.1 Asset Pipline

like image 2
linojon Avatar answered Oct 14 '22 08:10

linojon