2

私のRailsアプリでは、ajaxリクエストを実行してアイテムIDをデータベースに追加することで、壁にあるものを非表示にできるようにしたいと考えています。

真似したいリクエストは次のとおりです。

Started POST "/report_fixed_vulns" for 127.0.0.1 at 2013-08-19 21:28:45 +0100
Processing by ReportFixedVulnsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"xxx", "report_fixed_vuln"=>{"report_id"=>"2", "vuln_id"=>"2", "user_id"=>"2"}, "commit"=>"Create Report fixed vuln"}

これを行うために、次のコードを使用してみました。

<%= button_to 'Submit', report_fixed_vuln_path(:report_fixed_vuln => {:report_id => @report_id, :vuln_id => plugin.first.id, :user_id => current_user.id}), :remote => true, :method => :put %>

ただし、これにより別のリクエストが生成されます。

Started PUT "/report_fixed_vulns/323?report_fixed_vuln%5Breport_id%5D=323&report_fixed_vuln%5Buser_id%5D=1&report_fixed_vuln%5Bvuln_id%5D=443" for 127.0.0.1 at 2013-08-19 21:32:51 +0100
Processing by ReportFixedVulnsController#update as JS
  Parameters: {"authenticity_token"=>"xxx", "report_fixed_vuln"=>{"report_id"=>"323", "user_id"=>"1", "vuln_id"=>"443"}, "id"=>"323"}

ここに私の質問があります: を使用して最初のリクエストを模倣する方法button_to(パラメーターを入力する必要はありません。パラメーターはページに既に存在します)

4

1 に答える 1