Commit 1bf32fd2 authored by April Guian's avatar April Guian

draft2

parent 8782a80e
...@@ -3,9 +3,10 @@ class CarLogsController < ApplicationController ...@@ -3,9 +3,10 @@ class CarLogsController < ApplicationController
def index def index
@records = CarLog.all @records = CarLog.all
if params[:q].present? # if params[:q].present?
@records = Housemate.where(plate_number: params[:q]) # @records = CarLog.where(plate_number: params[:q])
end # end
render "car_logs/index.html.erb" render "car_logs/index.html.erb"
end end
......
<h1>Add New Record</h1>
<%= form_tag("/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="pabebe">Pabebe</option>
<option value="qt">Qt</option>
<option value="meh">Meh</option>
</select>
<div></div>
<label>Brand:</label>
<select name="rate" class="u-full-width">
<option value="pabebe">Pabebe</option>
<option value="qt">Qt</option>
<option value="meh">Meh</option>
</select>
<div></div>
<input type="submit" value="Create Record"/>
<% end %>
<hr>
<a href="/car_logs">Go to Car Log Records</a>
<div></div>
<a href="/">Back to 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>
<tr>
<th>ID</th>
<th>Plate Number</th>
<th>Time In</th>
<th>Time Out</th>
<th>Color</th>
<th>Brand</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% @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 %>
</tbody>
</table>
<hr>
<a href="/create">Add New Record</a>
<div></div>
<a href="/">Back Home</a>
...@@ -3,4 +3,5 @@ Rails.application.routes.draw do ...@@ -3,4 +3,5 @@ Rails.application.routes.draw do
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" post "/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