Commit 87e419c3 authored by Jasmine Principe's avatar Jasmine Principe

updated

parent 8782a80e
...@@ -3,11 +3,11 @@ class CarLogsController < ApplicationController ...@@ -3,11 +3,11 @@ class CarLogsController < ApplicationController
def index def index
@records = CarLog.all @records = CarLog.all
if params[:q].present? render "car_logs/index.html.erb"
@records = Housemate.where(plate_number: params[:q])
end end
render "car_logs/index.html.erb" def create_page
render "car_logs/create_page.html.erb"
end end
def create def create
...@@ -19,7 +19,7 @@ class CarLogsController < ApplicationController ...@@ -19,7 +19,7 @@ class CarLogsController < ApplicationController
record.brand = params[:brand] record.brand = params[:brand]
record.save record.save
redirect_to "car_logs/create.html.erb" redirect_to("/car_logs")
end end
end end
\ No newline at end of file
<h1>Add New Record</h1>
<%= form_tag("/car_logs/create", method: "post") do %>
<label>Plate Number</label>
<input type="text" name="plate_number"/>
<div></div>
<label>Time Out:</label>
<input type="text" name="time_out"/>
<div></div>
<label>Color:</label>
<select name="rate" class="u-full-width">
<option value="" disabled="disabled" selected="selected">Select..</option>
<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>
<div></div>
<label>Brand:</label>
<select name="rate" class="u-full-width">
<option value="" disabled="disabled" selected="selected">Select..</option>
<option value="Honda">Honda</option>
<option value="Toyota">Toyota</option>
<option value="Ford">Ford</option>
<option value="Chevrolet">Chevrolet</option>
<option value="Audi">Audi</option>
<option value="Porsche">Porsche</option>
</select>
<div></div>
<input type="submit" value="Save"/>
<% end %>
<hr>
<a href="/car_logs">Car Logs</a>
<div></div>
<a href="/">Home</a>
\ No newline at end of file
<h1>Car Log Records</h1>
<%= form_tag("/car_logs", method: "get") do %>
<input type="text" name="q">
<input type="submit" value="Search">
<% end %>
<hr>
<table>
<thead>
<td>ID</td>
<td>Plate Number</td>
<td>Time In</td>
<td>Time Out</td>
<td>Color</td>
<td>Brand</td>
<td colspan="3"></td>
</thead>
<% @records.each do |record| %>
<tr>
<td><%= record.id %></td>
<td><%= record.plate_number %></td>
<td><%= record.time_in %></td>
<td><%= record.time_out %></td>
<td><%= record.color %></td>
<td><%= record.brand %></td>
</tr>
<% end %>
</table>
<hr>
<a href="/create_new">Add New Record</a>
<div></div>
<a href="/">Home</a>
...@@ -4,4 +4,4 @@ ...@@ -4,4 +4,4 @@
<h2>Guian, April</h2> <h2>Guian, April</h2>
<h2>Principe, Jasmine</h2> <h2>Principe, Jasmine</h2>
<a href="/car_logs">Go to Car Logs</a> <a href="/">Home</a>
\ No newline at end of file \ No newline at end of file
<h1>Parking Lot Logging System</h1> <h1>Parking Lot Logging System</h1>
<a href="/car_logs">Car Logs</a>
<a href="about">See member list</a> <a href="about">The Developers</a>
\ No newline at end of file \ No newline at end of file
...@@ -2,5 +2,6 @@ Rails.application.routes.draw do ...@@ -2,5 +2,6 @@ Rails.application.routes.draw do
root to: "pages#index" root to: "pages#index"
get "/about", to: "pages#about" get "/about", to: "pages#about"
get "/car_logs", to: "car_logs#index" get "/car_logs", to: "car_logs#index"
post "/create", to: "car_logs#create" get "/create_new", to: "car_logs#create_page"
post "/car_logs/create", to: "car_logs#create"
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