I know this question was asked a lot of times, but none of the recipes helped me so far.
I have an application written in Ruby 2.0.0, Rails 4.0.0 with following routes.rb:
resources :announcements do
end
Which generates the following routes:
announcements GET /announcements(.:format) announcements#index
POST /announcements(.:format) announcements#create
new_announcement GET /announcements/new(.:format) announcements#new
edit_announcement GET /announcements/:id/edit(.:format) announcements#edit
announcement GET /announcements/:id(.:format) announcements#show
PATCH /announcements/:id(.:format) announcements#update
PUT /announcements/:id(.:format) announcements#update
DELETE /announcements/:id(.:format) announcements#destroy
Then in HTML I use very simple construct:
<%= button_to 'X', announcement, method: :delete %>
Which produces the following code:
<form method="post" class="button_to" action="/announcements/525c0d28b9fd0171e2000003">
<div>
<input type="hidden" value="delete" name="_method">
<input type="submit" value="X">
<input type="hidden" value="DR+QjuAG9npqqWRV16Zq0G4Cq3lGpNHY0qjV8LJpUZo=" name="authenticity_token">
</div>
</form>
Everything looks pretty simple, clean and correct. Nevertheless I'm getting "No Route Matches" error. Why?