Integrating CKEditor with Rails 3.2

后端 未结 12 1465
一整个雨季
一整个雨季 2021-02-02 04:27

Similar to Integrating CKEditor with Rails 3.1 Asset Pipline

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

相关标签:
12条回答
  • 2021-02-02 04:42

    Have similar issue. For me it was fixed by overriding default precompile task (I used Rails 4 and CkEditor 4).

    1. Add to application.rb config.assets.precompile += ['ckeditor/*']
    2. In application.js //= require ckeditor/init
    3. Create file lib/tasks/precompile_hook and paste text from this answer Precompile hook
    0 讨论(0)
  • 2021-02-02 04:45

    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']
    
    0 讨论(0)
  • 2021-02-02 04:48

    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/';
    0 讨论(0)
  • 2021-02-02 04:48

    I fought with this issue for some hours, but the problem was not with CKEditor, but with my code. I included the ckeditor.js script inside my partial view which was rendered via AJAX and yes, you guessed it, wasn't working. Once I moved the script including inside the master layout (_Layout), the issue was solved. Of course, this happened to me while working in ASP.NET MVC. For other web frameworks, I have no solution.

    0 讨论(0)
  • 2021-02-02 04:50

    This is just an addition. I tried all this and it did not work for me so what i did was to change my ckeditor gem to gem 'ckeditor'

    And added this to my application.js

    //= require ckeditor/init
    

    Then to precompile my assets, i added this to my production.rb file

    config.assets.precompile += Ckeditor.assets
    

    and it all worked like magic

    0 讨论(0)
  • 2021-02-02 04:55

    Finally an easy working solution.

    Download the CKEditor Zip file, extract the files and place them in the sub directory “javascripts/ckeditor”, add the main JS file to the layout..

    javascript_include_tag 'ckeditor/ckeditor.js'
    

    ..and write a bit JavaScript code which replaces textareas by CKEditor instances:

    $(document).ready(function() {
       if ($('textarea').length > 0) {       
         var data = $('textarea');
         $.each(data, function(i) {
           CKEDITOR.replace(data[i].id);
         });     
       }  
    });
    

    Credit Source

    0 讨论(0)
提交回复
热议问题