Commit 59dbbc58 authored by Bianca Tarun's avatar Bianca Tarun

Added add method, index method, add.html.erb and /carlog/index.html.erb

parent 80306559
class CarLogController < ApplicationController
\ No newline at end of file
class CarLogController < ApplicationController
def index
@car_logs = Carlog.all
render "/car_log/index.html.erb"
end
def add
car = CarLog.new
car.plate_number = params[:plate_number]
car.time_in = params[:time_in]
car.time_out = params[:time_out]
car.color = params[:color]
car.brand = params[:brand]
car.save
end
end
\ No newline at end of file
<h1>Add Car</h1>
<%= form_tag("/car_log/add", method: "post") do %>
<label>Plate Number:</label>
<input type= "text" name= "plate_number"/>
<hr>
<label>Time In:</label>
<input type= "datetime" name= "time_in"/>
<hr>
<label>Time Out:</label>
<input type= "datetime" name= "time_out"/>
<hr>
<label>Color:</label>
<select name= "color">
<option value = "red">Red</option>
<option value = "white">White</option>
<option value = "blue">Blue</option>
<option value = "green">Green</option>
<option value = "orange">Orange</option>
<option value = "pink">Pink</option>
<option value = "black">Black</option>
<option value = "others">Others</option>
</select>
<hr>
<label>Brand:</label>
<select name= "brand">
<option value = "Honda">Honda</option>
<option value = "Toyota">Toyota</option>
<option value = "Ford">Ford</option>
<option value = "Suzuki">Suzuki</option>
<option value = "Chevrolet">Chevrolet</option>
<option value = "Mitsubishi">Mitsubishi</option>
<option value = "Subaru">Subaru</option>
<option value = "Nissan">Nissan</option>
<option value = "Others">Others</option>
</select>
<hr>
<input type= "submit" value= "Add Car"/>
<% end %>
<hr>
<a href= "/car_log">View All Cars</a>
\ No newline at end of file
<table>
<thead>
<tr>
<th>Plate Number</th>
<th></th>
<th></th>
<th></th>
<th>Time In</th>
<th></th>
<th></th>
<th></th>
<th>Time Out</th>
<th></th>
<th></th>
<th></th>
<th>Color</th>
<th></th>
<th></th>
<th></th>
<th>Brand</th>
</tr>
</thead>
<tbody>
<% @car_logs.each do |car| %>
<tr>
<td><%= car.plate_number %></td>
<td></td>
<td></td>
<td></td>
<td><%= car.time_in %></td>
<td></td>
<td></td>
<td></td>
<td><%= car.time_out %></td>
<td></td>
<td></td>
<td></td>
<td><%= car.color %></td>
<td></td>
<td></td>
<td></td>
<td><%= car.brand %></td>
</tr>
<% end %>
</tbody>
</table>
<hr>
<a href= "/car_log/add">Add New Sport</a>
<hr>
<a href= "/">Go back to Homepage</a>
\ 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