Rails 3 : Can't get form_for to work as a 'delete' following the RESTful achitecture => always giving a ROUTING ERROR

Posted by Alex on Stack Overflow See other posts from Stack Overflow or by Alex
Published on 2011-01-17T10:45:28Z Indexed on 2011/01/17 10:53 UTC
Read the original article Hit count: 234

Filed under:
|
|
|

I have a very simple render that goes as follow:

<%= form_for(:relationships, :url => relationships_path, :html => {:method => 'delete'}) do |f| %>
<div><%= f.hidden_field :user_id_to_unfollow, :value => @user.id %></div>
<div class="actions"><%= f.submit "Unfollow" %></div>
<% end %>

When I submit this form it will always give me a

Routing Error
No route matches "/relationships"

on my page.

In my relationships controller, I have created all the propers methods:

def create    
...
end

def destroy    
...
end

def update    
...
end

def show    
...
end

And in my routes config I have made sure to allow all routes for the relationships controller

resources :relationships

But I can't seem to get into the destroy method of the controller :(

However if I remove the

:html => {:method => 'delete'}

method parameter in the form_for then I get to the create method of the controller no pb.

I don't get it....

Alex

© Stack Overflow or respective owner

Related posts about ruby-on-rails

Related posts about rest