Commit a9a1b2b3 authored by Dominique Pascasio's avatar Dominique Pascasio

Dom

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