volunteers_controller.rb 1.45 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
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
20
        format.html { redirect_to @volunteer, notice: t('volunteer_created') }
21
22
23
24
25
26
27
28
29
      else
        format.html { render :new }
      end
    end
  end

  def update
    respond_to do |format|
      if @volunteer.update(volunteer_params)
30
        format.html { redirect_to @volunteer, notice: t('volunteer_updated') }
31
32
33
34
35
36
37
38
39
      else
        format.html { render :edit }
      end
    end
  end

  def destroy
    @volunteer.destroy
    respond_to do |format|
40
      format.html { redirect_to volunteers_url, notice: t('volunteer_destroyed') }
41
42
43
44
45
46
47
48
49
50
    end
  end

  private

  def set_volunteer
    @volunteer = Volunteer.find(params[:id])
  end

  def volunteer_params
51
    params.require(:volunteer).permit(:first_name, :last_name, :date_of_birth, :gender, :avatar,
52
53
      :street, :zip, :city, :nationality, :additional_nationality, :email, :phone, :profession,
      :education, :motivation, :experience, :expectations, :strengths, :skills, :interests, :state,
54
      :duration, :man, :woman, :family, :kid, :sport, :creative, :music, :culture, :training,
55
      :german_course, :adults, :teenagers, :children, :region)
56
57
  end
end