Sha256: 8faf0a70b855a2d5cc14afa7b4901c5cc6c6da6f030815e7e10b6cf0e559ca8d

Contents?: true

Size: 1.64 KB

Versions: 6

Compression:

Stored size: 1.64 KB

Contents

require_dependency "tang/application_controller"

module Tang
  class Admin::PlansController < Admin::ApplicationController
    before_action :set_plan, only: [:show, :edit, :update, :destroy]

    # GET /plans
    def index
      @plans = Plan.all.
                    paginate(page: params[:page]).
                    order(:name)
    end

    # GET /plans/1
    def show
    end

    # GET /plans/new
    def new
      @plan = Plan.new
    end

    # GET /plans/1/edit
    def edit
    end

    # POST /plans
    def create
      @plan = Plan.new(plan_create_params)

      if @plan.save
        redirect_to [:admin, @plan], notice: 'Plan was successfully created.'
      else
        render :new
      end
    end

    # PATCH/PUT /plans/1
    def update
      if @plan.update(plan_update_params)
        redirect_to [:admin, @plan], notice: 'Plan was successfully updated.'
      else
        render :edit
      end
    end

    # DELETE /plans/1
    def destroy
      @plan.destroy
      redirect_to admin_plans_url, notice: 'Plan was successfully destroyed.'
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_plan
        @plan = Plan.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def plan_create_params
        params.require(:plan).permit(:stripe_id, :amount, :currency, :interval, :interval_count, :name, :statement_descriptor, :trial_period_days, :order, :highlight, :features, :description, :group)
      end

      def plan_update_params
        params.require(:plan).permit(:name, :order, :highlight, :features, :description, :group)
      end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
tang-0.2.2 app/controllers/tang/admin/plans_controller.rb
tang-0.2.1 app/controllers/tang/admin/plans_controller.rb
tang-0.2.0 app/controllers/tang/admin/plans_controller.rb
tang-0.1.0 app/controllers/tang/admin/plans_controller.rb
tang-0.0.9 app/controllers/tang/admin/plans_controller.rb
tang-0.0.8 app/controllers/tang/admin/plans_controller.rb