我已成功安装redactorJS
,使用gem redactor-rails
进入我的Rails项目。我已将js
和css
个文件包含在资产中。然后,我运行了rails generate redactor:install
和rails 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
。* FROMredactor_assets
WHEREredactor_assets
。type
IN(' RedactorRails :: Picture' )和redactor_assets
。user_id
= 20
无法找到检索redactor_assets.user_id
的原因。