Class: CompsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/comps_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/comps_controller.rb', line 10

def create
  @show = Show.find(params[:show_id])
  @selected_tickets = params[:selected_tickets]
  @comp = Comp.new(@show, @selected_tickets, params[:person_id], current_user)
  unless @comp.valid?
     flash[:alert] = @comp.errors.full_messages.to_sentence
     render :new and return
  end

  @comp.reason = params[:reason_for_comp]

  with_confirmation_comp do
    @comp.submit
    if @comp.uncomped_count > 0
      flash[:alert] = "Comped #{to_plural(@comp.comped_count, 'ticket')}. #{to_plural(@comp.uncomped_count, 'ticket')} could not be comped."
    else
      flash[:notice] = "Comped #{to_plural(@comp.comped_count, 'ticket')}."
    end

    redirect_to event_show_url(@show.event, @show)
  end
end

#newObject



2
3
4
5
6
7
8
# File 'app/controllers/comps_controller.rb', line 2

def new
  @show = Show.find(params[:show_id])
  @selected_tickets = params[:selected_tickets]

  @comp = Comp.new(@show, @selected_tickets, nil, current_user)
  render :new
end

#with_confirmation_compObject



33
34
35
36
37
38
39
40
# File 'app/controllers/comps_controller.rb', line 33

def with_confirmation_comp
  if params[:confirmed].blank?
    flash[:info] = "Please confirm your changes before we save them."
    render 'comp_confirm' and return
  else
    yield
  end
end