Sha256: 2cea3839da27d16e19fbcd2a32a186e22c5e723f89005b28bbb9786329cef974

Contents?: true

Size: 1.46 KB

Versions: 11

Compression:

Stored size: 1.46 KB

Contents

class PassTypesController < ArtfullyOseController
  requires_kit :passes

  def index
    @pass_types = current_organization.pass_types.includes(:passes).paginate(:page => params[:page], :per_page => 50)

    respond_to do |format|
      format.html

      format.csv do
        @filename = 'pass_types.csv'
        @csv_string = @pass_types.to_comma
        send_data @csv_string, :filename => @filename, :type => 'text/csv', :disposition => 'attachment'
      end
    end
  end

  def new
    @pass_type = PassType.new
  end

  def create
    @pass_type = PassType.new(params[:pass_type])
    @pass_type.organization = current_organization
    unless @pass_type.save
      flash[:error] = @pass_type.errors.full_messages.to_sentence
      render "new" and return
    end
    redirect_to pass_types_path
  end

  def edit
    @pass_type = current_user.current_organization.pass_types.where(:id => params[:id]).first
  end

  def destroy
    @pass_type = current_user.current_organization.pass_types.where(:id => params[:id]).first
    if @pass_type.destroyable?
      @pass_type.destroy
      flash[:notice] = "We've deleted this pass type"
    else
      flash[:error] = "Can't delete this pass type because you've sold some passes for this type."
    end
    redirect_to pass_types_path
  end

  def update
    @pass_type = PassType.find(params[:id])
    @pass_type.update_attributes(params[:pass_type])
    flash[:notice] = "Your changes have been saved"
    redirect_to pass_types_path
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/controllers/pass_types_controller.rb
artfully_ose-1.3.0.pre3 app/controllers/pass_types_controller.rb
artfully_ose-1.3.0.pre2 app/controllers/pass_types_controller.rb
artfully_ose-1.3.0.pre1 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/pass_types_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/pass_types_controller.rb