繁体   English   中英

在Heroku生产中预编译时,Rails ckeditor gem js错误

[英]Rails ckeditor gem js error when precompiled on Heroku production

我在Rails 3.2.11 / Ruby 1.9.3上使用了ckeditorhttps://github.com/galetahub/ckeditor )gem。

我在使用资源后得到了这个JS错误rake assets:precompile在生产环境中rake assets:precompile (部署到Heroku)

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

我不知道它是否相关,但我已经将错误(使用Chrome的webdev工具)跟踪到一个启动的块:

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

我假设是插件负责将粗体,斜体,下划线和其他此类字体样式按钮添加到工具栏。

textarea仍在显示没有CKEditor UI。

我正在使用rubygems的最新版本(4.0.4)。

我在我的application.js有这个:

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

我在app/assets/ckeditor/config.js有一个自定义配置文件,并在app/assets/ckeditor/plugins/有两个自定义插件。

我还使用RAILS_ENV=production本地测试它,也没有工作。

我找到了导致这个问题的原因。 这是一个古老的uglifier版本。 将它从〜> 1.0.3移动到> = 1.0.3(更新到2.1.1)解决了这个问题。

一些可能会有所帮助的事情

那些//= require行需要放在你的application.js文件中,你的Gemfile应该只有gem 'ckeditor'

它也应该是:

app/assets/javascripts/ckeditor/config.jsapp/assets/javascripts/ckeditor/plugins

而不是

app/assets/ckeditor/config.jsapp/assets/ckeditor/plugins

最后你可以使用

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

在你的意见。 请注意,这是一个SimpleForm输入。

我使用了ckeditor-rails gem,一切都很顺利。

希望能帮助到你。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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