[英]Rails ckeditor gem js error when precompiled on Heroku production
我在Rails 3.2.11 / Ruby 1.9.3上使用了ckeditor
( https://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.js
和app/assets/javascripts/ckeditor/plugins
而不是
app/assets/ckeditor/config.js
和app/assets/ckeditor/plugins
最后你可以使用
<%= f.input :content, :input_html => {:class => 'ckeditor', :rows => "10"}%>
在你的意見。 請注意,這是一個SimpleForm輸入。
我使用了ckeditor-rails gem,一切都很順利。
希望能幫助到你。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.