Sha256: f57a1cd4cacb1c2c8f28097bf34c402b7995619506ddb053f2d6d91b5b511620

Contents?: true

Size: 1.23 KB

Versions: 28

Compression:

Stored size: 1.23 KB

Contents

class TicketTypesController < ArtfullyOseController
  before_filter :find_section

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

  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

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

  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

  private

    def find_section
      @section = Section.find(params[:section_id]) if params[:section_id].present?
    end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
artfully_ose-1.2.0 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.23 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.21 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.15 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.12 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.11 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.10 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.9 app/controllers/ticket_types_controller.rb
artfully_ose-1.2.0.pre.8 app/controllers/ticket_types_controller.rb