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

时间:2013-04-22 11:27:59

标签: javascript ruby-on-rails ckeditor

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

我在生产环境(部署到Heroku)上rake assets:precompile之后发现了这个JS错误

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在本地对其进行了测试,但也无法使用。

2 个答案:

答案 0 :(得分:1)

我发现了造成这个问题的原因。这是一个古老的uglifier版本。将其从〜&gt;移开1.0.3到&gt; = 1.0.3(更新到2.1.1)解决了这个问题。

答案 1 :(得分:0)

可能有所帮助的一些事情

这些//= 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宝石,一切都很顺利。

希望它有所帮助。