mirror of
https://github.com/fspc/bike-database.git
synced 2025-02-23 01:23:24 -05:00
clean up views & volunteer display
This commit is contained in:
parent
65216e3835
commit
8b17200b97
@ -20,10 +20,8 @@ class BikesController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @bike.save
|
||||
format.html { redirect_to @bike, notice: 'Bike was successfully created.' }
|
||||
format.json { render action: 'show', status: :created, location: @bike }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @bike.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -32,10 +30,8 @@ class BikesController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @bike.update(bike_params)
|
||||
format.html { redirect_to @bike, notice: 'Bike was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render action: 'edit' }
|
||||
format.json { render json: @bike.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -44,7 +40,6 @@ class BikesController < ApplicationController
|
||||
@bike.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to bikes_url }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -4,27 +4,38 @@ class VolunteersController < ApplicationController
|
||||
def index
|
||||
@volunteers = Volunteer.all
|
||||
end
|
||||
|
||||
def show; end
|
||||
|
||||
def new
|
||||
@volunteer = Volunteer.new
|
||||
end
|
||||
|
||||
def edit; end
|
||||
|
||||
def create
|
||||
@volunteer = Volunteer.new(volunteer_params)
|
||||
respond_to do |format|
|
||||
if @volunteer.save
|
||||
format.html { redirect_to @volunteer, notice: 'Volunteer was successfully created.' }
|
||||
format.json { render action: 'show', status: :created, location: @bike }
|
||||
else
|
||||
format.html { render action: 'new' }
|
||||
format.json { render json: @volunteer.errors, status: :unprocessable_entity }
|
||||
end
|
||||
if @volunteer.save
|
||||
redirect_to @volunteer, notice: 'Volunteer was successfully created.'
|
||||
else
|
||||
render action: 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def update; end
|
||||
def destroy; end
|
||||
def update
|
||||
if @volunteer.update(volunteer_params)
|
||||
redirect_to @volunteer, notice: 'Volunteer was successfully updated.'
|
||||
else
|
||||
render action: 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@volunteer.destroy
|
||||
redirect_to volunteers_url
|
||||
end
|
||||
|
||||
|
||||
|
||||
private
|
||||
def set_volunteer
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="container">
|
||||
|
||||
<h1>Listing bikes</h1>
|
||||
<h1>Bikes</h1>
|
||||
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
|
@ -1,4 +0,0 @@
|
||||
json.array!(@bikes) do |bike|
|
||||
json.extract! bike,
|
||||
json.url bike_url(bike, format: :json)
|
||||
end
|
@ -1 +0,0 @@
|
||||
json.extract! @bike, :created_at, :updated_at
|
@ -6,13 +6,13 @@
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<%= link_to "Bicycle Project Tracker", root_path, :class=>"navbar-brand" %>
|
||||
<%= link_to "Bicycle Projects", root_path, :class=>"navbar-brand" %>
|
||||
</div>
|
||||
|
||||
<div class="navbar-collapse collapse navbar-responsive-collapse" id='collapse-1'>
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
<li><%= link_to "Bike Tracker", bikes_path %></li>
|
||||
<li><%= link_to "Volunteer Tracker", volunteers_path %></li>
|
||||
<li><%= link_to "Bikes", bikes_path %></li>
|
||||
<li><%= link_to "Volunteers", volunteers_path %></li>
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
@ -1,2 +1,6 @@
|
||||
<h1>Bicycle Data Tracker</h1>
|
||||
<%= link_to "Track Bicycles", bikes_path %>
|
||||
<div class="container">
|
||||
<h1>Bicycle Data Tracker</h1>
|
||||
<%= link_to "Bikes", bikes_path %>
|
||||
<br>
|
||||
<%= link_to "Volunteers", volunteers_path %>
|
||||
</div>
|
||||
|
@ -0,0 +1,8 @@
|
||||
<div class="container">
|
||||
<h1>Editing Volunteer Information</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @volunteer %> |
|
||||
<%= link_to 'Back', volunteers_path %>
|
||||
</div>
|
@ -1,9 +1,30 @@
|
||||
<div class="container">
|
||||
<h1>Volunteer Listing</h1>
|
||||
<% @volunteers.each do |volunteer| %>
|
||||
<%= volunteer.name %>
|
||||
<br>
|
||||
<% end %>
|
||||
<h1>Volunteers</h1>
|
||||
<table class="table table-striped table-bordered table-hover">
|
||||
<thead>
|
||||
<tr>
|
||||
<th> Name </th>
|
||||
<th> Phone </th>
|
||||
<th> Email </th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @volunteers.each do |volunteer| %>
|
||||
<tr>
|
||||
<td><%= volunteer.name %></td>
|
||||
<td><%= volunteer.phone %></td>
|
||||
<td><%= volunteer.email %></td>
|
||||
<td><%= link_to 'Show', volunteer %></td>
|
||||
<td><%= link_to 'Edit', edit_volunteer_path(volunteer) %></td>
|
||||
<td><%= link_to 'Destroy', volunteer, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<%= link_to '+ Add Volunteer', new_volunteer_path, class: "btn btn-default" %>
|
||||
</div>
|
||||
|
||||
|
@ -5,5 +5,5 @@
|
||||
<% end %>
|
||||
|
||||
<%= link_to 'Edit', edit_volunteer_path(@volunteer) %> |
|
||||
<%= link_to 'Back', volunteer_path %>
|
||||
<%= link_to 'Back', volunteers_path %>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user