Rails 3 form_for helper无法正确提交操作

时间:2010-12-02 00:40:12

标签: forms ruby-on-rails-3

我有这样的表格:

<% @page_title = "Delete Technician: #{@technician.name}" %>  

<%= link_to("<< Back to List", {:action => 'list', :id => @technician.id}, :class => 'back-link') %>  

<div class="technician delete">  
<h2>Delete Technician</h2>  

<%= form_for(:technician, :url => {:action => 'destroy', :id => @technician.id}) do |f| %>

<p>Are you sure you want to permanently delete this technician?</p>

<p class="reference-name"><%= @technician.name %></p>

<div class="form-buttons">
  <%= submit_tag("Delete Technician") %>
</div>

<% end %>
</div>  

当我点击提交按钮时,这是我得到的网址:
    www.site.com/technicians/1

而不是
    www.site.com/technicians/destroy/1

我没有正确使用form_for帮助程序,还是在某处配置?

1 个答案:

答案 0 :(得分:0)

你让它变得比它需要的更复杂。当链接或按钮执行时,没有理由使用表单。为什么不呢这个

<p>Are you sure you want to permanently delete this technician</p>
<div> <%= link_to "Delete", technician_path(@technician), :method => :delete %> </div>

就是这样。