0

マーキュリー編集者

insideというサブフォルダーへの変更と移動は既に除外mercury.jsしました。application.jsrequire_tree .require_directory .mercury.jsmercuryassets/javascripts

したがって、私のアプリの他のすべてはうまく機能しており、水銀をまったくロードしていません.

layouts/mercury.html.erb

    <%= stylesheet_link_tag    'mercury/mercury' %>
    <%= javascript_include_tag 'jquery-1.7', 'mercury/mercury' %>

    <script type="text/javascript">
          // Set to the url that you want to save any given page to, leave null for default handling.
          var saveUrl = null;

          // Instantiate the PageEditor
          new Mercury.PageEditor(saveUrl, {
            saveStyle:  'form', // 'form', or 'json' (default json)
            saveMethod: null, // 'PUT', or 'POST', (create, vs. update -- default PUT)
            visible:    true  // boolean - if the interface should start visible or not
          });
</script>

しかし、エディターが読み込まれると、次のエラーが発生します。

TypeError: 'undefined' is not a constructor (evaluating 'new Mercury.PageEditor')

サブフォルダに何かありますか?

4

1 に答える 1

1

これは、水銀ライブラリが「水銀」パスを占有しているためであると確信しています。

ルートをレーキすると、これが表示されます

Routes for Mercury::Engine:
mercury_editor  /editor(/*requested_uri)(.:format)        mercury#edit
                /mercury/:type/:resource(.:format)        mercury#resource
                /mercury/snippets/:name/options(.:format) mercury#snippet_options
                /mercury/snippets/:name/preview(.:format) mercury#snippet_preview

yourhost://assets/mercury/mercury.js をリクエストすると得られるファイルがmercuryのライブラリファイルなのでちょっとややこしいです。フォルダに「mercury_assets」または実際には「mercury」以外の名前を付けると、機能します。

水銀が必要なライブラリを見つけることができると確信していない限り、ルートを変更しようとすることをいじりません。

于 2013-01-29T14:23:33.803 に答える