I'm making a simple calorie counter, using http://guides.rubyonrails.org/getting_started.html as a reference. I'm trying to add a Delete button, but every time I try to run it, I hit an error:
No route matches [DELETE] "/calorieinput.1"
I know the issue is that there's a period instead of a slash, which has been a common occurrence in this app. I fixed it before in the form_for
but there isn't one for DELETE. I'll try to add everything needed, I am new to posting so I'm sorry in advance if I forget anything.
def destroy
@calinput = Calorie.find(params[:id])
@calinput.destroy
redirect_to calorieinput_index_path
end
Prefix Verb URI Pattern Controller#Action
calorieinput_index GET /calorieinput(.:format) calorieinput#index
POST /calorieinput(.:format) calorieinput#create
new_calorieinput GET /calorieinput/new(.:format) calorieinput#new
edit_calorieinput GET /calorieinput/:id/edit(.:format) calorieinput#edit
calorieinput GET /calorieinput/:id(.:format) calorieinput#show
PATCH /calorieinput/:id(.:format) calorieinput#update
PUT /calorieinput/:id(.:format) calorieinput#update
DELETE /calorieinput/:id(.:format) calorieinput#destroy
root GET / welcome#index
<% @calinput.each do |calorieinputs| %>
<tr>
<td><%= calorieinputs.food %></td>
<td><%= calorieinputs.calories %></td>
<td><%= link_to 'View', calorieinput_path(calorieinputs) %></td>
<td><%= link_to 'Edit', edit_calorieinput_path(calorieinputs) %></td>
<td><%= link_to 'Delete', calorieinput_index_path(calorieinputs),
method: :delete,
data: { confirm: 'Are you sure you want to delete this post?' } %></td>
</tr>
<% end %>
Any feedback is appreciated.