简体   繁体   中英

Rails ckeditor gem js error when precompiled on Heroku production

I'm using the ckeditor ( https://github.com/galetahub/ckeditor ) gem on Rails 3.2.11 / Ruby 1.9.3.

I've been getting this JS error after I do rake assets:precompile on production environment (deployed to Heroku)

Uncaught TypeError: Object #<Object> has no method 'apply' 

I don't know if it's relevant, but I've traced the error (using Chrome's webdev tools) to a block that starts:

CKEDITOR.plugins.add("basicstyles", ...)

which I assume is the plugin responsible for adding the bold, italic, underline, and other such font style buttons to the toolbar.

The textarea is still showing without the CKEditor UI.

I'm using the latest version (4.0.4) from rubygems.

I have this in my application.js :

//= require 'ckeditor/init'
//= require 'ckeditor/config'

I have a custom config file in app/assets/ckeditor/config.js and have two custom plugins in app/assets/ckeditor/plugins/ .

I've also tested it locally using RAILS_ENV=production and also not working.

I found what's causing the issue. It's an old uglifier version. Moving it from ~> 1.0.3 to >= 1.0.3 (which updated to 2.1.1) solved the issue.

A couple of things that may help

Those //= require lines need to go in your application.js file, your Gemfile should just have gem 'ckeditor' .

also it should be :

app/assets/javascripts/ckeditor/config.js and app/assets/javascripts/ckeditor/plugins

rather than

app/assets/ckeditor/config.js and app/assets/ckeditor/plugins

Finally you can use

<%= f.input :content, :input_html => {:class => 'ckeditor', :rows => "10"}%>

in your views. Note that this is a SimpleForm input.

I used the ckeditor-rails gem and everything went pretty smoothly for me.

Hope it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM