【发布时间】:2017-10-24 02:04:04
【问题描述】:
我正在使用 rails 5 api,并尝试使用 angularjs 1 以一种形式实现 ckeditor wysiwyg。我正在使用 rails 5.1.4、ckeditor 4.2 和回形针 5.1.0。
我已按照此处的指示:https://github.com/galetahub/ckeditor 进行 gem 实现并运行了生成器:
rails generate ckeditor:install --orm=active_record --backend=paperclip
当尝试“浏览服务器”或通过 ckeditor 将图像上传到服务器时,我正在执行以下 Get 请求:
Started GET "/ckeditor/pictures?CKEditor=js-ckeditor&CKEditorFuncNum=1&langCode=en" for 172.23.0.1 at 2017-10-24 01:59:04 +0000
然后我得到以下错误:
ActionController::RoutingError (undefined method `layout' for Ckeditor::ApplicationController:Class):
ckeditor (4.2.4) app/controllers/ckeditor/application_controller.rb:2:in `<class:ApplicationController>'
ckeditor (4.2.4) app/controllers/ckeditor/application_controller.rb:1:in `<top (required)>'
这是错误来自的控制器:https://github.com/galetahub/ckeditor/blob/master/app/controllers/ckeditor/application_controller.rb
编辑: 原来 rails 5 api 不包括 ActionView::Layouts 开箱即用,所以我将以下内容添加到我的 ApplicationController:
include ::ActionView::Layouts
这处理了未定义的方法“布局”。但是,现在在将 Get 请求传递给 index 操作后,我又遇到了来自同一个 ckeditor 控制器的另一个错误。 我还使用 devise_token_auth 和 pundit 进行授权和身份验证。
Processing by Ckeditor::PicturesController#index as HTML
Parameters: {"CKEditor"=>"js-ckeditor", "CKEditorFuncNum"=>"1", "langCode"=>"en"}
Completed 500 Internal Server Error in 149ms (ActiveRecord: 0.0ms)
NoMethodError (undefined method `ckeditor_authorize!' for #<Ckeditor::PicturesController:0x007f5e7ac7dc30>):
【问题讨论】:
-
现在我有一个临时修复。首先,问题在于 ActionController::API。我无法立即弄清楚需要包含哪些模块才能使其顺利运行。所以,现在我已经将 ActionController::API 更改为 ActionController:Base 以包含所有相关的 base 模块。我将通过将我的控制器祖先切换回 API 来更新这个答案,并在我有时间时包含必要的模块。如果其他人已经解决了这个问题,请随时回答:)
标签: ruby-on-rails ckeditor paperclip