5

私は Rails 3.2.3 を使用しています。TinyMCE が本番環境で読み込まれると、次の 4 つの 404 が返されます。

"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//langs/en.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//plugins/fullscreen/editor_plugin.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//themes/advanced/editor_template.js"
"NetworkError: 404 Not Found - http://[my-domain]/[current-path]//plugins/media/editor_plugin.js"

これらのファイルは、ソースにリストされていないため、tiny_mce.js から非同期的に呼び出される可能性があります。私のjsは次のようになります:

tinyMCE.init({
    theme: "advanced",
    mode: "textareas",
    plugins: "fullscreen, media",
    height: 300,
    relative_urls :true,
    theme_advanced_toolbar_location : "top",
    theme_advanced_toolbar_align : "left",
    theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,search,replace,|,bullist,numlist,|,outdent,indent,|undo,redo,|,link,unlink,anchor,image,cleanup,code,|,insertdate,inserttime,preview,hr,removeformat,visualaid,|,sub,sup,|,fullscreen,spellchecker",
    theme_advanced_buttons2 : "styleselect,formatselect,imageListBox,media",
    theme_advanced_buttons3 : "",
    editor_selector : "mceEditor",
    extended_valid_elements : "form[action|accept|accept-charset|enctype|method|name|onsubmit|id|name]",
    convert_urls : false,
    remove_script_host : false
});

function toggleTinyMCE(id) {
    if (!tinyMCE.get(id))
        tinyMCE.execCommand('mceAddControl', false, id);
    else
        tinyMCE.execCommand('mceRemoveControl', false, id);
}

すべての TinyMCE ファイルはディレクトリ app/assets/javascripts/tiny_mce にあるため、init パラメータに と を追加しようdocument_base_urlbase_urlしましたが、設定した内容に関係なく、Firebug で TinyMCE を調べると、それらの値が表示されないことがわかります入力したものに変更します。

tinyMCE 用の kete による Rails プラグインが存在することは承知していますが、その READMEには、Rails >= 3.1 には推奨されないと記載されています。

4

2 に答える 2

0

これが役に立つかどうかはわかりませんが、試してみてください。tinymce FAQ の相対 URL と絶対 URL に関するセクションは次のとおりです

于 2012-07-17T15:22:26.597 に答える
0

document_base_url を変更する必要はありません。tinymce をページに直接追加できます。

<script type="text/javascript" src="/assets/vendor/tiny_mce/tiny_mce.js"></script>

そして、config/application.rb に追加することで、tinymce からのすべてのファイルを make shure アセット pipline にコンパイルします。

config.assets.precompile << 'vendor/tiny_mce/*'
于 2013-10-04T12:54:40.247 に答える