使用redactorJS上传图片,虽然已成功上传到服务器但未在编辑器中显示

时间:2017-09-19 11:51:08

标签: ruby-on-rails redactor.js

我已成功安装redactorJS,使用gem redactor-rails进入我的Rails项目。我已将jscss个文件包含在资产中。然后,我运行了rails generate redactor:installrails generate redactor:config。它创建了模型,上传者,路线和迁移。第二个命令创建了一个config.js文件:

window.init_redactor = function(){
  var csrf_token = $('meta[name=csrf-token]').attr('content');
  var csrf_param = $('meta[name=csrf-param]').attr('content');
  var params;
  if (csrf_param !== undefined && csrf_token !== undefined) {
      params = csrf_param + "=" + encodeURIComponent(csrf_token);
  }
  $('.redactor').redactor({
        // You can specify, which ones plugins you need.
        // If you want to use plugins, you have add plugins to your
        // application.js and application.css files and uncomment the line below:
        // "plugins": ['fontsize', 'fontcolor', 'fontfamily', 'fullscreen', 'textdirection', 'clips'],
        imageUpload: "/redactor_rails/pictures?" + params,
        imageGetJson :"/redactor_rails/pictures",
        fileUpload: "/redactor_rails/documents?" + params,
        fileGetJson: "/redactor_rails/documents",
        path: "/assets/redactor-rails",
        css :"style.css",
      });
};

$(document).on( 'ready page:load', window.init_redactor );

问题是图像已上传,但它们未显示在编辑器中,图像标记的src属性也是空白。我错过了什么,或者,也许,我以错误的方式做所有事情?提前谢谢。

修改

出于某种原因,当我走这条路线时:redactor_rails/pictures因此我可以获得json张图片,我收到此错误:

  

Mysql2 ::错误:未知列' redactor_assets.user_id' in' where子句':SELECT redactor_assets。* FROM redactor_assets WHERE redactor_assetstype IN(' RedactorRails :: Picture' )和redactor_assetsuser_id = 20

无法找到检索redactor_assets.user_id的原因。

0 个答案:

没有答案