ruby - Rails - delete method not working -
i trying delete entry specified in docs keep getting en error stating nomethoderror in tasks#show
, entry not deleted.
index.html.erb:
<%= link_to 'delete', destroy_task_path(task['id']), data: { confirm: 'are sure?' } %>
route.rb:
delete '/tasks/:id', to: 'tasks#destroy', as: 'destroy_task' resources :tasks root 'home#index'
tasks_controller.rb
def destroy uri = uri.parse("http://localhost/tasks/public/api/tasks/"+params[:id]) http = net::http.new(uri.host, uri.port) request = net::http::delete.new(uri.path) redirect_to :tasks, notice: 'task destroyed.' end
what doing wrong here?! , why redirected show?!
you missed in link_to
call method: :delete
, otherwise call.