I have a controller which has no show action.
The current destroy looks like this:
<td><%= link_to 'Destroy', subscriber, :confirm => 'Are you sure?', :method => :delete %></td>
I do not want it to point to {subscriber}, as that route does not exist. Instead I want it to direct to the subscribers index
<td><%= link_to 'Destroy', subscribers_path, :confirm => 'Are you sure?', :method => :delete %></td>
However when I do this I get the following error:
No route matches [DELETE] "/subscribers"
What am I doing wrong here?
UPDATE:
These are my routes:
resources :subscribers
match 'subscribe' => 'Subscribers#subscribe'
match 'unsubscribe' => 'Subscribers#unsubscribe'
As you say that route doesn’t exist, I assume you aren’t using resource routing. That means you probably have something like
None of these will actually match a delete request, which you can verify by running
rake routesfrom the app root.You could adjust it like the following, to make it match:
Also, this might make more sense with more information, but it seems like the deviation from a more traditional REST-based approach may cause an unnecessary and possibly confusing lack of clarity while maintaining the application.