我的_form.html.erb目前在编辑游戏时遇到问题。我的这个类的代码如下:
<%= form_for @game, :html => { :multipart => true } do |f| %>
<% if @game.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@game.errors.count, "error") %> prohibited this game from being saved:</h2>
<ul>
<% @game.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="field">
<div id="p1"><%= f.label :game_name %> </div>
<%= f.text_field :game_name %>
</div>
<br />
<div class="field">
<div id="p1"><%= f.label :genre %> </div>
<%= f.text_field :genre %>
</div>
<br />
<div class="field">
<div id="p1"><%= f.label :console %> </div>
<%= f.select :console, Game::CONSOLE_OPTIONS, :prompt => 'Select' %>
</div>
<br />
<div class="field">
<div id="p1"><%= f.label :condition %> </div>
<%= f.text_field :condition %>
</div>
<br />
<div class="field">
<div id="p1"><%= f.label :description %> </div>
<%= f.text_area :description, :rows => 6 %>
</div>
<%= f.file_field :photo %>
<br />
<div class="actions">
<%= f.submit %>
<%= button_to 'Destroy', root_url, :confirm => 'Are You Sure?', :method => :delete %>
</div>
<% end %>
我遇到的问题如下。如果我单击删除按钮它将删除记录没有问题,但如果我单击更新按钮它也删除记录。如果我取出删除命令,那么它会更新。如何在履行各自职责的同时让两者一起展示?
答案 0 :(得分:0)
您需要从form_for
更新中提取您的销毁按钮。