私のケースでは、createとeditの両方で同じフォームpartialを使用します。 部分多少のようになります(私はHAMLを使用)= button_toは他のフォームに既に存在する場合はフォームを生成しません
=form_tag ({:action => params[:action]}, :multipart => true)
=text_field :newsletter, :title
=text_area :newsletter, :body
=file_field :newsletter,:attachment
-if params[:action] == "preview"
=button_to "select contacts and send", :action => "contacts"
=submit_tag "save and preview"
が、HTML出力で
...
<input type="submit" value="select contacts and send"/>
<input type="hidden" value="rwYnZlEpWV4dR89zjgprEALBYmP0xqM3lnKt9JDLyak=" name="authenticity_token"/>
<input type="submit" value="save and preview" name="commit"/>
...
なぜbutton_toがボタンにフォームを生成しないのですか?
解決策はボタンを部分的に外に保ち、フォームあたり1つのみ、 ですが、同じフォームで2つのボタンを使用するにはどうすればよいですか?
編集: 別の回避策は、コントローラにそれらを分離、button_toを押すと、フォームを送信している場合はJavaScriptで設定されている非表示のチェックボックスになり