Ruby on rails 3 Ckeditor在根URI中搜索资产,而它';的应用程序位于子URI上

Ruby on rails 3 Ckeditor在根URI中搜索资产,而它';的应用程序位于子URI上,ruby-on-rails-3,ckeditor,asset-pipeline,Ruby On Rails 3,Ckeditor,Asset Pipeline,我花了两天时间试图修复这个bug,但我真的没有更多的想法或工具来解决它。我想知道这里是否有人能帮我 我正在尝试修复一个使用ckeditor gem的网站源代码。ckeditor gem提供了一个嵌入式web文本编辑器。问题是,当网站被放置在一个子目录中时,gem不能完成它的工作。如果将网站放在根目录(如www.domain.com)中,它会工作得很好,但当我将其放在子目录(如www.domain.com/website)中时,它不会显示文本编辑器 未显示编辑器的原因是应用程序试图在服务器的根目录

我花了两天时间试图修复这个bug,但我真的没有更多的想法或工具来解决它。我想知道这里是否有人能帮我

我正在尝试修复一个使用ckeditor gem的网站源代码。ckeditor gem提供了一个嵌入式web文本编辑器。问题是,当网站被放置在一个子目录中时,gem不能完成它的工作。如果将网站放在根目录(如www.domain.com)中,它会工作得很好,但当我将其放在子目录(如www.domain.com/website)中时,它不会显示文本编辑器

未显示编辑器的原因是应用程序试图在服务器的根目录中查找ckeditor gem的资产:

Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/config.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/skins/kama/editor.css?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/lang/pt-br.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/plugins/embed/plugin.js?t=C3HA5RM
Failed to load resource: the server responded with a status of 404 (Not Found)             http://domain.com/assets/ckeditor/plugins/attachment/plugin.js?t=C3HA5RM
当正确的地址是www.domain.com/网站时/assets/ckeditor/config.js?t=C3HA5RM

我真的搜索了所有的网页,试图找到解决这个问题的办法,但我发现只有少数类似的情况没有给我一个解决办法

在github中,用户Jronalo的问题与我的问题完全相同。但我试图实施他的解决方案,但没有成功。 在这次提交中,在ckeditor存储库中,这个bug似乎已经修复,但即使在我的gem上有这个修复(ckeditor 4.0.2和rails 3.2.2),它仍然会丢失SubUri上的资产

我还尝试手动操作CKEDITOR_BASEPATH和CKEDITOR.relative_url,但没有成功


有人知道如何解决这个问题吗?非常感谢。

删除您的ckeditor配置外部插件

加载资源失败:服务器响应状态为404(未找到) 加载资源失败:服务器响应状态为404(未找到) 而且它的工作

我的配置:

/*
Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/

CKEDITOR.editorConfig = function( config )
{
    // Define changes to default configuration here. For example:
    config.language = I18n.locale;
    // config.uiColor = '#AADC6E';

  /* Filebrowser routes */
  // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
  config.filebrowserBrowseUrl = "/ckeditor/attachment_files";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
  config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";

  // The location of a script that handles file uploads in the Flash dialog.
  config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
  config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";

  // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
  config.filebrowserImageBrowseUrl = "/ckeditor/pictures";

  // The location of a script that handles file uploads in the Image dialog.
  config.filebrowserImageUploadUrl = "/ckeditor/pictures";

  // The location of a script that handles file uploads.
  config.filebrowserUploadUrl = "/ckeditor/attachment_files";

  // Rails CSRF token
  config.filebrowserParams = function(){
    var csrf_token = jQuery('meta[name=csrf-token]').attr('content'),
        csrf_param = jQuery('meta[name=csrf-param]').attr('content'),
        params = new Object();

    if (csrf_param !== undefined && csrf_token !== undefined) {
      params[csrf_param] = csrf_token;
    }

    return params;
  };

  config.addQueryString = function (url, params) {
    var queryString = [];

    if (!params)
      return url;
    else {
      for (var i in params)
        queryString.push(i + "=" + encodeURIComponent(params[ i ]));
    }

    return url + ( ( url.indexOf("?") != -1 ) ? "&" : "?" ) + queryString.join("&");
  };

  // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
  CKEDITOR.on('dialogDefinition', function (ev) {
    // Take the dialog name and its definition from the event data.
    var dialogName = ev.data.name;
    var dialogDefinition = ev.data.definition;
    var content, upload;

    if ($.inArray(dialogName, ['link', 'image', 'attachment', 'flash']) > -1) {
      content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
      upload = (content == null ? null : content.get('upload'));

      if (upload && upload.filebrowser['params'] == null) {
        upload.filebrowser['params'] = config.filebrowserParams();
        upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
      }
    }
  });

  /* Extra plugins */
  // works only with en, ru, uk locales
//  config.extraPlugins = "embed,attachment";

    //for orfografii
  config.disableNativeSpellChecker = false;
//  config.removePlugins = 'contextmenu';


  /* Toolbars */
  config.toolbar = 'Mini';
  config.toolbar_Mini =
    [
        ['Source','-','Preview'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord'],
        ['Undo','Redo','-','SelectAll','RemoveFormat'],
//        ['Styles','Format'],
      ['Subscript', 'Superscript'],
//      ['Subscript', 'Superscript', 'TextColor'],
//        ['Maximize','-','About'],
        ['Bold','Italic','Underline'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote']//,
//        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
//        ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
//        ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
    ];

  config.toolbar = 'VeryEasy';
  config.toolbar_VeryEasy =
    [
        ['Source','-','Preview'],
        ['Cut','Copy','Paste','PasteText','PasteFromWord'],
        ['Undo','Redo','-','SelectAll','RemoveFormat'],
//        ['Styles','Format'],
      ['Subscript', 'Superscript', 'TextColor'],
        ['Maximize','-','About'],
        ['Bold','Italic','Underline','Strike'], ['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
//        ['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
//        ['Link','Unlink','Anchor'], ['Image', 'Attachment', 'Flash', 'Embed'],
        ['Table','HorizontalRule','Smiley','SpecialChar','PageBreak']
    ];

  config.toolbar = 'Easy';
  config.toolbar_Easy =
      [
        ['Source', '-', 'Preview'],
        ['Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord'],
        ['Undo', 'Redo', '-', 'SelectAll', 'RemoveFormat'],
        ['Styles', 'Format'],
        ['Subscript', 'Superscript', 'TextColor'],
        ['Maximize', '-', 'About'],
        '/',
        ['Bold', 'Italic', 'Underline', 'Strike'],
        ['NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', 'Blockquote'],
        ['JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock'],
        ['Link', 'Unlink', 'Anchor'],
        ['Image', 'Attachment', 'Flash', 'Embed'],
        ['Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak']
      ];
  config.jqueryOverrideVal = true;
};

我在使用ckeditor搜索根目录上的皮肤时遇到了问题,因为在整个页面加载之后,我以友好方式加载了ckeditor.js

我在中找到的解决方案 是在调用CKEDITOR.js之前设置全局变量CKEDITOR_BASEPATH