5

ブラックライトアプリケーションでrails-3.2.1を使用しています

link_to タグで remote_function を呼び出そうとしています。

<%= link_to_document document, :label=>document_show_link_field, :onclick =>     remote_function(:controller => 'catalog', :action => 'save_user_history') %>

これにより、次のエラーが発生します

undefined method `remote_function' for #<#<Class:0x2ff0dc0>:0x2f4af38>.

誰かが理由を知っていますか?

4

2 に答える 2

5

この関数は、Rails 3.1 でフレームワークから削除され、 prototype-rails gemに移動されたPrototype ヘルパーの一部でした。

于 2012-06-06T11:57:59.633 に答える
2

いつでも通常の link_to を使用できます。

<%= link_to "Save User History", save_user_history_catalogs_path %>

または、ajax 関数の場合は、次のようになります。

<a id="save_user_history">Save User History</a>

そしてあなたのjavascriptファイルで:

$("#save_user_history").click(function() {
  $.post("/catalogs/save_user_history", function(data) {
    ....
于 2012-06-06T12:04:04.353 に答える