9

私は次のようなものを持っています

semantic_form_for @whatever, :url => whatever_url

からを生成する

method="post"

私はそれを置く必要があります、私はすでに試しました:

semantic_form_for @whatever, :url => whatever_url, :html => {:method => "put"}

semantic_form_for @whatever, :url => whatever_url, :html => {:method => :put}

semantic_form_for @whatever, :url => whatever_url, :html_args => {:method => :put}

効果なし。それがどのように行われたかについてのアイデアはありますか?

4

2 に答える 2

15

http://www.rubydoc.info/gems/formtastic/0.9.10/Formtastic/SemanticFormHelperを参照 して試してください:

  <% semantic_form_for :whatever, @whatever :url => posts_path, :html => {:method => :put} do |f| %>
    ...
  <% end %>
于 2011-01-06T01:22:29.513 に答える
7

このようなフォームを生成していますか?

<form action="..." method="POST">
...

もしそうなら、おそらくまだ PUT リクエストを作成しています。Rails は、代わりに _method 属性を使用して POST、PUT、または DELETE リクエストを決定します。これが機能していることを確認する最善の方法は、ログをチェックして、PUT 要求が送信されていることを確認することです。次のように非表示の属性をフォームに追加することで、これを強制的に実行することもできます。

<input type="hidden" name="_method" value="put" />
于 2011-01-05T23:01:01.633 に答える