clarion/app/controllers/public/volunteers_controller.rb

42 lines
1.2 KiB
Ruby
Raw Permalink Normal View History

2015-10-21 23:13:39 +03:00
module Public
class VolunteersController < Public::ApplicationController
def new
@volunteer = current_conference.volunteers.build
end
def edit
@volunteer = current_conference.volunteers.find_by! unique_id: params[:id]
end
def create
@volunteer = current_conference.volunteers.build volunteer_params
if @volunteer.save
2019-04-28 21:10:54 +03:00
flash[:notice] = I18n.t("views.volunteers.successful_application")
2015-10-21 23:13:39 +03:00
redirect_to edit_volunteer_path(@volunteer.unique_id)
else
render :new, status: :unprocessable_entity
end
end
def update
@volunteer = current_conference.volunteers.find_by! unique_id: params[:id]
if @volunteer.update volunteer_params
2019-04-28 21:10:54 +03:00
flash[:notice] = I18n.t("views.volunteers.successful_application_edit")
2015-10-21 23:13:39 +03:00
redirect_to edit_volunteer_path(@volunteer.unique_id)
else
render :edit, status: :unprocessable_entity
end
end
private
def volunteer_params
params.require(:volunteer).permit(
:name, :picture, :email, :phone, :tshirt_size, :tshirt_cut,
:food_preferences, :previous_experience, :notes, :language,
volunteer_team_ids: []
)
end
end
end