ruby - Rails DELETE putting a period before :id -
i'm making simple calorie counter, using http://guides.rubyonrails.org/getting_started.html reference. i'm trying add delete button, every time try run it, hit error:
no route matches [delete] "/calorieinput.1"
i know issue there's period instead of slash, has been common occurrence in app. fixed before in form_for
there isn't 1 delete. i'll try add needed, new posting i'm sorry in advance if 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 /calorieinput(.:format) calorieinput#index post /calorieinput(.:format) calorieinput#create new_calorieinput /calorieinput/new(.:format) calorieinput#new edit_calorieinput /calorieinput/:id/edit(.:format) calorieinput#edit calorieinput /calorieinput/:id(.:format) calorieinput#show patch /calorieinput/:id(.:format) calorieinput#update put /calorieinput/:id(.:format) calorieinput#update delete /calorieinput/:id(.:format) calorieinput#destroy root / welcome#index
<% @calinput.each |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 sure want delete post?' } %></td> </tr> <% end %>
any feedback appreciated.
i realized issue wrong path in delete link. referencing index instead of show route. sorry waste time people.
Comments
Post a Comment