Rails 3.1 ckeditor

前端 未结 4 1887
死守一世寂寞
死守一世寂寞 2021-02-10 06:41

So I just tried to install ckeditor in rails, however it doesn\'t look like its working.

Here is what I did

added these lines to my gemfile

gem \         


        
相关标签:
4条回答
  • 2021-02-10 06:54

    I had the same setup as you and the same issue. With jalagrange's example app as a comparison to mine, I eventually found the issue to be in development.rb. I had to remove this line:

    config.assets.debug = true
    

    It worked for me with after that.

    0 讨论(0)
  • 2021-02-10 06:57

    STEP 1: Add gem 'paperclip' and gem "ckeditor" in your gemfile.

    STEP 2: Bundle Install.

    STEP 3: rails generate ckeditor:install --orm=active_record --backend=paperclip

    STEP 4: Place config.autoload_paths += %W(#{config.root}/app/models/ckeditor) in application.rb

    STEP 5: Place mount Ckeditor::Engine => "/ckeditor" if not present already and run db:migrate

    STEP 6: Open application.html.erb and place this <%= javascript_include_tag 'ckeditor/ckeditor.js' %> in header.

    STEP 7: Place this in footer(above the body tag) in application.html.erb

    <script type="text/javascript">$(document).ready(function() {
        if ($('textarea').length > 0) {
            var data = $('textarea');
            $.each(data, function(i) {
                CKEDITOR.replace(data[i].id);
            });
        }
    });</script>
    

    STEP 8: Restart the WEBrick SERVER. That's it.

    0 讨论(0)
  • 2021-02-10 06:58

    This works like a charm, just tested it on rails 3.1.rc6. Also be cautious of the gem you are using. As of the moment of this post, the oficial gem was not working and was waiting for a pull request, so be sure to use fxposter's version of the gem in your gemfile.

    https://github.com/fxposter/rails_3_1_with_ckeditor_and_carrierwave

    0 讨论(0)
  • 2021-02-10 07:01

    I had a similar issue when I was setting it up a while ago. I gave up on the gem eventually. The problem was getting ckeditor to behave in the asset pipeline, but I had mixed results depending on the browser (of course IE was the problem). Here is what worked for me:

    Download ckeditor package from their site and drop in to public/ckeditor.

    Then, directly include the javascript files.

    <%= javascript_include_tag "/ckeditor/ckeditor" %>
    <%= javascript_include_tag "/ckeditor/adapters/jquery" %>
    

    Not exactly elegant, but it worked and haven't had to touch it since.

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