loos
11 years ago
14 changed files with 197 additions and 13 deletions
@ -0,0 +1,37 @@ |
|||
class VolunteersController < ApplicationController |
|||
before_action :set_volunteer, only: [:show, :edit, :update, :destroy] |
|||
|
|||
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 |
|||
end |
|||
end |
|||
|
|||
def update; end |
|||
def destroy; end |
|||
|
|||
private |
|||
def set_volunteer |
|||
@volunteer = Volunteer.find(params[:id]) |
|||
end |
|||
|
|||
def volunteer_params |
|||
params.require(:volunteer).permit(:name, :email, :phone) |
|||
end |
|||
end |
@ -0,0 +1,2 @@ |
|||
class Volunteer < ActiveRecord::Base |
|||
end |
@ -0,0 +1,23 @@ |
|||
<% disabled ||= false %> |
|||
|
|||
<div class="form-group"> |
|||
<%= f.label "Name", class: "col-sm-2 control-label" %> |
|||
<div class="col-sm-10"> |
|||
<%= f.text_field :name, class: "form-control", disabled: disabled %> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<%= f.label "Email address:", class: "col-sm-2 control-label" %> |
|||
<div class="col-sm-10"> |
|||
<%= f.text_field :email, class: "form-control", disabled: disabled %> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="form-group"> |
|||
<%= f.label "Phone Number:", class: "col-sm-2 control-label" %> |
|||
<div class="col-sm-10"> |
|||
<%= f.text_field :phone, class: "form-control", disabled: disabled %> |
|||
</div> |
|||
</div> |
|||
|
@ -0,0 +1,23 @@ |
|||
<div class="container"> |
|||
<%= form_for @volunteer, html: {class: 'form-horizontal'} do |f| %> |
|||
<% if @volunteer.errors.any? %> |
|||
<div id="error_explanation"> |
|||
<h2><%= pluralize(@volunteer.errors.count, "error") %> prohibited this volunteer from being saved:</h2> |
|||
|
|||
<ul> |
|||
<% @volunteer.errors.full_messages.each do |msg| %> |
|||
<li><%= msg %></li> |
|||
<% end %> |
|||
</ul> |
|||
</div> |
|||
<% end %> |
|||
|
|||
<%= render 'fields', f: f %> |
|||
|
|||
<div class="row"> |
|||
<div class="actions col-sm-offset-2"> |
|||
<%= f.submit class: "btn btn-default" %> |
|||
</div> |
|||
</div> |
|||
<% end %> |
|||
</div> |
@ -0,0 +1,9 @@ |
|||
<div class="container"> |
|||
<h1>Volunteer Listing</h1> |
|||
<% @volunteers.each do |volunteer| %> |
|||
<%= volunteer.name %> |
|||
<br> |
|||
<% end %> |
|||
<%= link_to '+ Add Volunteer', new_volunteer_path, class: "btn btn-default" %> |
|||
</div> |
|||
|
@ -0,0 +1,5 @@ |
|||
<h1>New Volunteer</h1> |
|||
|
|||
<%= render 'form' %> |
|||
|
|||
<%= link_to 'Back', volunteers_path %> |
@ -0,0 +1,9 @@ |
|||
<div class="container"> |
|||
<p id="notice"><%= notice %></p> |
|||
<%= form_for(@volunteer) do |f| %> |
|||
<%= render 'fields', f: f, disabled: true %> |
|||
<% end %> |
|||
|
|||
<%= link_to 'Edit', edit_volunteer_path(@volunteer) %> | |
|||
<%= link_to 'Back', volunteer_path %> |
|||
</div> |
@ -1,4 +1,5 @@ |
|||
Bikedb::Application.routes.draw do |
|||
root "static_pages#home" |
|||
resources :bikes |
|||
resources :volunteers |
|||
end |
|||
|
@ -0,0 +1,23 @@ |
|||
class CreateVolunteers < ActiveRecord::Migration |
|||
def change |
|||
create_table :volunteers do |t| |
|||
t.string :name |
|||
t.string :email |
|||
t.string :phone |
|||
t.date :orientation_date |
|||
t.integer :other_volunteer_hours |
|||
t.text :referral |
|||
t.text :reason |
|||
t.text :skills |
|||
t.text :wants |
|||
t.boolean :interested_in_improving |
|||
t.boolean :available_weekends |
|||
t.boolean :available_weekdays |
|||
t.boolean :available_shorter_hours |
|||
t.boolean :available_longer_hours |
|||
t.boolean :flexible |
|||
t.text :questions |
|||
t.text :improve_orientation |
|||
end |
|||
end |
|||
end |
Loading…
Reference in new issue