Commit a9a1b2b3 authored by Dominique Pascasio's avatar Dominique Pascasio

Dom

parent ab36fe82
File added
File added
class LogsController < ApplicationController class LogsController < ApplicationController
def index def index
@CarLogs = CarLog.all @CarLogs = CarLog.all
render "logs/index.html.erb" render "logs/index.html.erb"
end end
def create def create
car = CarLog.new car = CarLog.new
car.plate_number = params[:plate_number] car.plate_number = params[:plate_number]
car.time_in = ::Time.zone ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime car.created = ::Time.zone ? ::Time.zone.now.to_datetime : ::Time.now.to_datetime
car.time_out = params[:time_out] car.time_in = params[:time_in]
car.color = params[:color] car.time_out = params[:time_out]
car.brand = params[:brand] car.color = params[:color]
car.save car.brand = params[:brand]
car.save
redirect_to("/logs")
end redirect_to("/logs")
end
def delete
id = params[:id] def delete
@car = CarLog.find(id.to_i) id = params[:id]
@car.destroy! @car = CarLog.find(id.to_i)
@car.destroy!
redirect_to("/logs")
end redirect_to("/logs")
end
end end
\ No newline at end of file
<h1>New Car</h1> <h1>New Car</h1>
<%= form_tag("/logs/create", method: "post") do %> <%= form_tag("/logs/create", method: "post") do %>
<input type="text" name="plate_number" placeholder="plate number"/><br> <input type="text" name="plate_number" placeholder="plate number"/><br>
<input type="time" name="time_out"/><br> <input type="time" name="time_in"/><br>
<select name="color"> <input type="time" name="time_out"/><br>
<option value="White">White</option> <select name="color">
<option value="Black">Black</option> <option value="White">White</option>
<option value="Silver">Silver</option> <option value="Black">Black</option>
<option value="Red">Red</option> <option value="Silver">Silver</option>
<option value="Blue">Blue</option> <option value="Red">Red</option>
<option value="Yellow">Yellow</option> <option value="Blue">Blue</option>
</select><br> <option value="Yellow">Yellow</option>
<select name="brand"> </select><br>
<option value="Honda">Honda</option> <select name="brand">
<option value="Toyota">Toyota</option> <option value="Honda">Honda</option>
<option value="Ford">Ford</option> <option value="Toyota">Toyota</option>
<option value="Subaru">Subaru</option> <option value="Ford">Ford</option>
<option value="BMW">BMW</option> <option value="Subaru">Subaru</option>
<option value="Mercedes Benz">Mercedes Benz</option> <option value="BMW">BMW</option>
<option value="Ferrari">Ferrari</option> <option value="Mercedes Benz">Mercedes Benz</option>
<option value="Hyundai">Hyundai</option> <option value="Ferrari">Ferrari</option>
</select><br> <option value="Hyundai">Hyundai</option>
<input type="submit" class="submit" value="SAVE"/> </select><br>
<% end %><br> <input type="submit" class="submit" value="SAVE"/>
<% end %><br>
<a href="/">Back to Home</a>
<a href="/">Back to Home</a>
<a class="button" href="/logs">Go to Parking Lot</a> <a class="button" href="/logs">Go to Parking Lot</a>
\ No newline at end of file
<h1>Car Logs</h1><br> <h1>Car Logs</h1><br>
<a href="/">Back to Home</a> <a href="/">Back to Home</a>
<a href="/add">Add Car</a> <a href="/add">Add Car</a>
<ul> <ul>
<% @CarLogs.each do |car| %> <% @CarLogs.each do |car| %>
<div class="col-md-3 well"> <div class="col-md-3 well">
<li> <li>
<%= "#{car.plate_number}" %><br> Plate: <%= "#{car.plate_number}" %><br>
<%= "#{car.time_in}" %><br> ID: <%= "#{car.id}" %><br>
<%= "#{car.time_out}" %><br> Created at: <%= "#{car.created}" %><br>
<%= "#{car.color}" %><br> Time in: <%= "#{car.time_in}" %><br>
<%= "#{car.brand}" %><br> Time out: <%= "#{car.time_out}" %><br>
<a href="/logs/delete/<%= car.id%>">Delete</a> Color: <%= "#{car.color}" %><br>
</li> Brand: <%= "#{car.brand}" %><br>
</div> <a href="/logs/delete/<%= car.id%>">Delete</a>
<% end %> </li>
</ul> </div>
<% end %>
</ul>
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