2014年9月13日 星期六

ckeditor setting

http://terrybu.blogspot.com/2014/07/getting-ckeditor-to-work-on-your-rails.html

 Go to your production.rb under config and set   config.serve_static_assets = true

add the  follow script to _form.html.erb

<script type='text/javascript' charset='UTF-8'>
  $(document).ready(function(){
    $('form[data-remote]').bind('ajax:before', function(){
      for (instance in CKEDITOR.instances){
        CKEDITOR.instances[instance].updateElement();
      }
    });
  });
</script>


also add
  <script type="text/javascript">
    var CKEDITOR_BASEPATH = '/assets/ckeditor/';
  </script>


add to config/application.rb

config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
config.assets.precompile += Ckeditor.assets
config.assets.precompile += %w(ckeditor/*)

in the first of application.html



Media Embedding with CKEditor + Rails 4.0
https://rjsteen.wordpress.com/2014/01/06/media-embedding-with-ckeditor-rails-4-0/

*do precompile to see the changes



Create config.js in public/assets/ckeditor/config.js

for mini toolbar and mediaembed

add //= require ckeditor/config in application.js

and raw for showing content of the ckeditor ex: <%= raw article.content %>


** gotta override config,js in new folder under javascript/ckeditor

it wont be changed in public/assets/ckeditor/config.js, when deploy to Heroku.