Commit f29f6e6f authored by Jasmine Principe's avatar Jasmine Principe

updateddeletebutton

parent b0b2c663
...@@ -159,3 +159,6 @@ DEPENDENCIES ...@@ -159,3 +159,6 @@ DEPENDENCIES
tzinfo-data tzinfo-data
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (~> 2.0) web-console (~> 2.0)
BUNDLED WITH
1.10.4
...@@ -28,9 +28,11 @@ class CarLogsController < ApplicationController ...@@ -28,9 +28,11 @@ class CarLogsController < ApplicationController
def delete def delete
car_log_to_delete = CarLog.find(record.id) id = params[:id]
car_log_to_delete.destroy! @records = CarLog.find(id.to_i)
@records.destroy
redirect_to("/car_logs")
end end
end end
\ No newline at end of file
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
<th> Time Out </th> <th> Time Out </th>
<th> Color </th> <th> Color </th>
<th> Brand </th> <th> Brand </th>
<th> </th>
</tr> </tr>
<% @records.each do |record| %> <% @records.each do |record| %>
...@@ -26,6 +27,7 @@ ...@@ -26,6 +27,7 @@
<td><%= record.time_out %></td> <td><%= record.time_out %></td>
<td><%= record.color %></td> <td><%= record.color %></td>
<td><%= record.brand %></td> <td><%= record.brand %></td>
<td><a href="car_logs/delete/<%= record.id %>">Delete </a></td>
</tr> </tr>
<% end %> <% end %>
</table> </table>
......
...@@ -4,5 +4,6 @@ Rails.application.routes.draw do ...@@ -4,5 +4,6 @@ Rails.application.routes.draw do
get "/car_logs", to: "car_logs#index" get "/car_logs", to: "car_logs#index"
get "/create_new", to: "car_logs#create_page" get "/create_new", to: "car_logs#create_page"
post "/car_logs/create", to: "car_logs#create" post "/car_logs/create", to: "car_logs#create"
get "/car_logs/delete/:id", to: "car_logs#delete"
end end
\ No newline at end of file
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