我想使用链接触发模型的远程操作。基本上所有这个链接需要做的是用一个参数触发一个方法。
这是我的代码:
= link_to 'Move Up', reorder_collection_folder_path(@collection, folder), :reorder => :up, :remote => true
这会按预期触发文件夹#重新排序控制器操作,但:reorder
参数未被传递。我的日志说:
Started GET "/collections/1/folders/1/reorder" for 127.0.0.1 at 2011-03-01 18:03:31 -0600
Processing by FoldersController#reorder as JS
Parameters: {"collection_id"=>"1", "id"=>"1"}
那么,我如何通过远程链接传递参数?我在这里做错了什么?
答案 0 :(得分:7)
找到了解决方案。
对于远程链接,代码应为:
= link_to 'Move Up', reorder_collection_folder_path(@collection, folder, :reorder=>:up), :remote => true
IE中的params需要进入路径助手。