modified car_log controller, car_log index, renamed add.html.erb to...

modified car_log  controller, car_log index, renamed add.html.erb to new.html.erb, modified routes.rb
parent 706635f2
......@@ -14,6 +14,16 @@ class CarLogsController < ApplicationController
car.color = params[:color]
car.brand = params[:brand]
car.save
redirect_to "/car_logs"
end
def delete
car_log_to_delete = CarLog.find(params[:id])
car_log_to_delete.destroy!
redirect_to "/car_logs"
end
def new
render "/car_logs/new.html.erb"
end
end
\ No newline at end of file
......@@ -40,11 +40,16 @@
<td></td>
<td></td>
<td><%= car.brand %></td>
<td></td>
<td></td>
<td></td>
<td><%= button_to "Remove Car", { id: car.id },
method: :delete, data: { confirm: "Are you sure?" } %></td>
</tr>
<% end %>
</tbody>
</table>
<hr>
<a href= "/car_logs/add">Add New Car</a>
<a href= "/car_logs/new"><button>Add New Car</button></a>
<hr>
<a href= "/">Go back to Homepage</a>
\ No newline at end of file
Rails.application.routes.draw do
root to: "pages#index"
get"/car_logs", to: "car_logs#index"
get"/car_logs/add", to: "car_logs#add"
get"/car_logs/new", to: "car_logs#new"
get"/car_logs/delete", to: "car_logs#delete"
post"/car_logs/add", to: "car_logs#add"
post"/car_logs/delete", to: "car_logs#delete"
delete"/car_logs", to: "car_logs#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