From 8b17200b9778391e817d09c7a5ea78ca452b3cb5 Mon Sep 17 00:00:00 2001 From: loos Date: Wed, 12 Mar 2014 19:58:06 -0500 Subject: [PATCH] clean up views & volunteer display --- app/controllers/bikes_controller.rb | 5 ---- app/controllers/volunteers_controller.rb | 31 ++++++++++++++++-------- app/views/bikes/index.html.erb | 2 +- app/views/bikes/index.json.jbuilder | 4 --- app/views/bikes/show.json.jbuilder | 1 - app/views/layouts/_navbar.html.erb | 6 ++--- app/views/static_pages/home.html.erb | 8 ++++-- app/views/volunteers/edit.html.erb | 8 ++++++ app/views/volunteers/index.html.erb | 31 ++++++++++++++++++++---- app/views/volunteers/show.html.erb | 2 +- 10 files changed, 66 insertions(+), 32 deletions(-) delete mode 100644 app/views/bikes/index.json.jbuilder delete mode 100644 app/views/bikes/show.json.jbuilder diff --git a/app/controllers/bikes_controller.rb b/app/controllers/bikes_controller.rb index 6dd8754..40f2389 100644 --- a/app/controllers/bikes_controller.rb +++ b/app/controllers/bikes_controller.rb @@ -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 diff --git a/app/controllers/volunteers_controller.rb b/app/controllers/volunteers_controller.rb index cdf9416..a2230d8 100644 --- a/app/controllers/volunteers_controller.rb +++ b/app/controllers/volunteers_controller.rb @@ -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 diff --git a/app/views/bikes/index.html.erb b/app/views/bikes/index.html.erb index 439f151..3c84141 100644 --- a/app/views/bikes/index.html.erb +++ b/app/views/bikes/index.html.erb @@ -1,6 +1,6 @@
-

Listing bikes

+

Bikes

diff --git a/app/views/bikes/index.json.jbuilder b/app/views/bikes/index.json.jbuilder deleted file mode 100644 index 29a7ea7..0000000 --- a/app/views/bikes/index.json.jbuilder +++ /dev/null @@ -1,4 +0,0 @@ -json.array!(@bikes) do |bike| - json.extract! bike, - json.url bike_url(bike, format: :json) -end \ No newline at end of file diff --git a/app/views/bikes/show.json.jbuilder b/app/views/bikes/show.json.jbuilder deleted file mode 100644 index 4cd5644..0000000 --- a/app/views/bikes/show.json.jbuilder +++ /dev/null @@ -1 +0,0 @@ -json.extract! @bike, :created_at, :updated_at diff --git a/app/views/layouts/_navbar.html.erb b/app/views/layouts/_navbar.html.erb index dd2ebb5..d159013 100644 --- a/app/views/layouts/_navbar.html.erb +++ b/app/views/layouts/_navbar.html.erb @@ -6,13 +6,13 @@ - <%= link_to "Bicycle Project Tracker", root_path, :class=>"navbar-brand" %> + <%= link_to "Bicycle Projects", root_path, :class=>"navbar-brand" %> diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb index a14b5e3..23b95c8 100644 --- a/app/views/static_pages/home.html.erb +++ b/app/views/static_pages/home.html.erb @@ -1,2 +1,6 @@ -

Bicycle Data Tracker

-<%= link_to "Track Bicycles", bikes_path %> +
+

Bicycle Data Tracker

+ <%= link_to "Bikes", bikes_path %> +
+ <%= link_to "Volunteers", volunteers_path %> +
diff --git a/app/views/volunteers/edit.html.erb b/app/views/volunteers/edit.html.erb index e69de29..676307d 100644 --- a/app/views/volunteers/edit.html.erb +++ b/app/views/volunteers/edit.html.erb @@ -0,0 +1,8 @@ +
+

Editing Volunteer Information

+ + <%= render 'form' %> + + <%= link_to 'Show', @volunteer %> | + <%= link_to 'Back', volunteers_path %> +
diff --git a/app/views/volunteers/index.html.erb b/app/views/volunteers/index.html.erb index 41ff977..22d8a1a 100644 --- a/app/views/volunteers/index.html.erb +++ b/app/views/volunteers/index.html.erb @@ -1,9 +1,30 @@
-

Volunteer Listing

- <% @volunteers.each do |volunteer| %> - <%= volunteer.name %> -
- <% end %> +

Volunteers

+
+ + + + + + + + + + + + <% @volunteers.each do |volunteer| %> + + + + + + + + + <% end %> + +
Name Phone Email
<%= volunteer.name %><%= volunteer.phone %><%= volunteer.email %><%= link_to 'Show', volunteer %><%= link_to 'Edit', edit_volunteer_path(volunteer) %><%= link_to 'Destroy', volunteer, method: :delete, data: { confirm: 'Are you sure?' } %>
+ <%= link_to '+ Add Volunteer', new_volunteer_path, class: "btn btn-default" %>
diff --git a/app/views/volunteers/show.html.erb b/app/views/volunteers/show.html.erb index 658b0fc..6155e1a 100644 --- a/app/views/volunteers/show.html.erb +++ b/app/views/volunteers/show.html.erb @@ -5,5 +5,5 @@ <% end %> <%= link_to 'Edit', edit_volunteer_path(@volunteer) %> | - <%= link_to 'Back', volunteer_path %> + <%= link_to 'Back', volunteers_path %>