Commit cf2850f3 authored by Christiana Tan's avatar Christiana Tan

Updated

parent 7764570d
...@@ -17,7 +17,7 @@ gem 'coffee-rails', '~> 4.1.0' ...@@ -17,7 +17,7 @@ gem 'coffee-rails', '~> 4.1.0'
# Use jquery as the JavaScript library # Use jquery as the JavaScript library
gem 'jquery-rails' gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks' gem 'turbolinks', '~> 2.5.3'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0' gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api. # bundle exec rake doc:rails generates the API under doc/api.
......
...@@ -133,7 +133,7 @@ GEM ...@@ -133,7 +133,7 @@ GEM
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.5) thread_safe (0.3.5)
tilt (1.4.1) tilt (1.4.1)
turbolinks (1.2.0) turbolinks (2.5.3)
coffee-rails coffee-rails
tzinfo (1.2.2) tzinfo (1.2.2)
thread_safe (~> 0.1) thread_safe (~> 0.1)
...@@ -160,7 +160,7 @@ DEPENDENCIES ...@@ -160,7 +160,7 @@ DEPENDENCIES
sdoc (~> 0.4.0) sdoc (~> 0.4.0)
spring spring
sqlite3 sqlite3
turbolinks turbolinks (~> 2.5.3)
uglifier (>= 1.3.0) uglifier (>= 1.3.0)
web-console (~> 2.0) web-console (~> 2.0)
......
...@@ -12,7 +12,7 @@ class CarLogsController < ApplicationController ...@@ -12,7 +12,7 @@ class CarLogsController < ApplicationController
@carlog = CarLog.find(params[:id]) @carlog = CarLog.find(params[:id])
@carlog.destroy() @carlog.destroy()
redirect_to #something redirect_to carlogs_path
end end
def new def new
...@@ -21,12 +21,17 @@ class CarLogsController < ApplicationController ...@@ -21,12 +21,17 @@ class CarLogsController < ApplicationController
end end
def create def create
@carlog = CarLog.new(carlog_params) @carlog = CarLog.new
@carlog.plate_number = params[:plate_number]
@carlog.brand = params[:brand]
@carlog.slot_number = params[:slot_number]
@carlog.is_taken = params[:is_taken]
if @carlog.save if @carlog.save
redirect_to show_carlog_path(@carlog) redirect_to carlogs_path, notice: "Car Record was successfully added"
else else
render 'new'
end end
end end
......
...@@ -7,6 +7,8 @@ ...@@ -7,6 +7,8 @@
<th> Brand </th> <th> Brand </th>
<th> Slot Number </th> <th> Slot Number </th>
<th> Created At </th> <th> Created At </th>
<th> Is Taken ?</th>
<th> Delete</th>
</thead> </thead>
<tbody> <tbody>
...@@ -16,7 +18,9 @@ ...@@ -16,7 +18,9 @@
<td><%=car.plate_number %> </td> <td><%=car.plate_number %> </td>
<td><%=car.brand%> </td> <td><%=car.brand%> </td>
<td><%=car.slot_number%> </td> <td><%=car.slot_number%> </td>
<td><%=car.create_at%> </td> <td><%=car.created_at%> </td>
<td><%= car.is_taken%> </td>
<td><%= link_to "Delete", carlog_destroy_path(car.id) %></td>
</tr> </tr>
<% end%> <% end%>
......
<h1> New Car Record</h1> <h1> New Car Record</h1>
<%= form_tag "/carlogs/create" do%> <%= form_tag '/carlogs/create' do %>
<form>
<!--ID <br/> <!--ID <br/>
<input type: "text" name = "ID"><br> --> <input type: "text" name = "ID"><br> -->
Plate Number <br/> Plate Number <br/>
<input type: "text" name = "Plate Number"><br> <input type= "text" name = "plate_number"><br>
Brand Brand
<select name = "brand"> <select name = "brand">
<option value = "honda">Honda</option> <option value = "honda">Honda</option>
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
</select> <br> </select> <br>
Slot Number <br/> Slot Number <br/>
<input type: "text" name = "Slot Number"><br> <input type= "text" name = "slot_number"><br>
Is Taken <br> Is Taken <br>
<input type="checkbox" name="is_taken"><br> <input type="checkbox" name="is_taken"><br>
</form>
<%=submit_tag "Submit" %>
<%= submit_tag "Submit" %>
<%end%> <%end%>
...@@ -4,9 +4,9 @@ Rails.application.routes.draw do ...@@ -4,9 +4,9 @@ Rails.application.routes.draw do
get '/carlogs/new', to: 'car_logs#new', as: :new_carlog get '/carlogs/new', to: 'car_logs#new', as: :new_carlog
get '/carlogs/:id', to: 'car_logs#show', as: :show_carlog get '/carlogs/:id', to: 'car_logs#destroy', as: :carlog_destroy
get '/carlogs', to: 'car_logs#create', as: :carlog post '/carlogs/create', to: 'car_logs#create', as: :carlog
# The priority is based upon order of creation: first created -> highest priority. # The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes". # See how all your routes lay out with "rake routes".
......
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