Commit 603358b5 authored by Jego Reyes's avatar Jego Reyes

added the delete function

parent 848989c6
......@@ -15,4 +15,12 @@ class CarsController < ApplicationController
redirect_to("/cars")
end
def delete
id = params[:id]
@cars = CarLog.find(id.to_i)
@cars.destroy
redirect_to("/cars")
end
end
\ No newline at end of file
......@@ -31,6 +31,8 @@
<td id="td2"><%= "#{car.created_at}"%></td>
<td> </td>
<td id="td2"><%= "#{car.id}"%></td>
<td> </td>
<td id="td2"> <a href="cars/delete/<%= car.id %>">Delete</a> </td>
</tr>
<% end %>
</table>
......
......@@ -5,4 +5,5 @@ Rails.application.routes.draw do
get("/cars", to: "cars#index")
post("/cars/create", to: "cars#create")
get("/add", to: "cars#add")
get("/cars/delete/:id", to: "cars#delete")
end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment