加载和搜索图像时出现Rails 5,Ckeditor和Paperclip错误

时间:2017-10-24 02:04:05

标签: ruby-on-rails ckeditor paperclip

我使用rails 5 api并尝试使用angularjs 1在表单中实现ckeditor wysiwyg。我使用rails 5.1.4,ckeditor 4.2和paperclip 5.1.0。

我已按照此处的说明进行操作:https://github.com/galetahub/ckeditor用于gem实现并运行生成器:

rails generate ckeditor:install --orm=active_record --backend=paperclip

尝试"浏览服务器"或通过ckeditor将图像上传到服务器我正在执行以下获取请求:

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

编辑:关闭导轨5 api不包含开箱即用的ActionView :: Layouts,所以我将以下内容添加到我的ApplicationController中:

include ::ActionView::Layouts

这照顾了未定义的方法&#39; layout&#39;。但是,现在我将Get请求传递给索引操作后,来自同一个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>):

1 个答案:

答案 0 :(得分:0)

这是CKeditor应用程序控制器,您收到错误,您应该使用link to the page

将此代码包含在您的问题中
class Ckeditor::ApplicationController < Ckeditor.parent_controller.constantize
  layout Ckeditor.controller_layout

  before_action :find_asset, only: [:destroy]
  before_action :ckeditor_authorize!
  before_action :authorize_resource

  protected

  def respond_with_asset(asset)
    asset_response = Ckeditor::AssetResponse.new(asset, request)

    if asset.save
      render asset_response.success(config.relative_url_root)
    else
      render asset_response.errors
    end
  end
end

我不知道为什么它不起作用,我不知道Ckeditor.controller_layout是什么..让我了解你的最新进展