Rails 3 form_for helper not submitting action correctly

I have this form:

<% @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>  

when I click on the submit button this is the url that I get: www.site.com/technicians/1

instead of www.site.com/technicians/destroy/1

am I not using the form_for helper correctly or is it a configuration somewhere?

Answers


You're making this more complicated than it needs to be. There is no reason for a form when a link or a button would do. Why not just this

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

That's it.


Need Your Help

Android - Design pattern - waiting for network

android multithreading android-ui

I have a few Activities implement an Interface ( called NetworkListener). When requesting information from a remote server, they spawn an instance of a class (called NetworkRequest). NetworkRequest...

Joomla Menu display in different website parts

joomla module

I'm using Joomla 1.5 version and a strange behaviour came up regarding menus displaying.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.