Class: ParticipantsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/participants_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject


6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/participants_controller.rb', line 6

def create
  if event.closed?
    flash[:alert] = t("flash.already_closed")
  elsif event.particpate(current_user)
    flash[:notice] = t("flash.now_participating")
  else
    flash[:alert] = t("flash.already_participating")
  end
  redirect_to event_path(event)
end

#destroyObject


17
18
19
20
21
22
23
24
25
# File 'app/controllers/participants_controller.rb', line 17

def destroy
  participant = Participant.find params[:id]
  if participant.owned_by? current_user
    participant.destroy
    redirect_to event_path(participant.event), notice: t("flash.dont_participate")
  else
    redirect_to event_path(participant.event), alert: t("flash.forbidden")
  end
end