Class: TicketTypesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/ticket_types_controller.rb', line 9

def create
  params[:ticket_type][:price] = TicketType.price_to_cents(params[:ticket_type][:price])
  @ticket_type = @section.ticket_types.build(params[:ticket_type].except!("section_id"))
  @ticket_type.show = @section.chart.show
  if @ticket_type.save
    flash[:notice] = "Your ticket type has been saved"
  else
    flash[:error] = "We couldn't save your ticket type because " + @section.errors.full_messages.to_sentence
  end

  redirect_to event_show_path(@section.chart.show.event, @section.chart.show)
end

#editObject



22
23
24
25
# File 'app/controllers/ticket_types_controller.rb', line 22

def edit
  @ticket_type = TicketType.find(params[:id])
  render :layout => false
end

#newObject



4
5
6
7
# File 'app/controllers/ticket_types_controller.rb', line 4

def new
  @ticket_type = @section.ticket_types.build
  render :layout => false
end

#updateObject



27
28
29
30
31
32
33
34
# File 'app/controllers/ticket_types_controller.rb', line 27

def update
  @ticket_type = TicketType.find(params[:id])
  @show = @ticket_type.show
  authorize! :manage, @show
  params[:ticket_type][:price] = TicketType.price_to_cents(params[:ticket_type][:price])
  @ticket_type.update_attributes(params[:ticket_type])
  redirect_to event_show_path(@show.event, @show)
end