added delete

parent e01cb97a
...@@ -17,4 +17,10 @@ class CarLogsController < ApplicationController ...@@ -17,4 +17,10 @@ class CarLogsController < ApplicationController
x.save x.save
redirect_to "/carlogs" redirect_to "/carlogs"
end end
def delete
id = params[:id]
@car = CarLog.find(id.to_i)
@car.destroy
redirect_to "/carlogs"
end
end end
\ No newline at end of file
...@@ -4,7 +4,7 @@ Rails.application.routes.draw do ...@@ -4,7 +4,7 @@ Rails.application.routes.draw do
get "/group", to: "pages#group" get "/group", to: "pages#group"
get "/carlogs/new", to: "car_logs#form" get "/carlogs/new", to: "car_logs#form"
post "/carlogs/create", to: "car_logs#create" post "/carlogs/create", to: "car_logs#create"
get "carlogs/delete/:id", to: "car_logs#delete"
end 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