Sha256: cbf00eb08840afb10467e6510f54d11f813d87c8c01a9f71a24301c8accbb066

Contents?: true

Size: 970 Bytes

Versions: 46

Compression:

Stored size: 970 Bytes

Contents

module DiscoApp::Admin::Concerns::PlansController
  extend ActiveSupport::Concern

  included do
    before_action :find_plan, only: [:edit, :update, :destroy]
  end

  def index
    @plans = DiscoApp::Plan.all
  end

  def new
    @plan = DiscoApp::Plan.new
  end

  def create
    @plan = DiscoApp::Plan.new(plan_params)
    if @plan.save
      redirect_to admin_plans_path
    else
      render 'new'
    end
  end

  def edit
  end

  def update
    if @plan.update_attributes(plan_params)
      redirect_to edit_admin_plan_path(@plan)
    else
      render 'edit'
    end
  end

  def destroy
    @plan.destroy
    redirect_to admin_plans_path
  end

  private

    def find_plan
      @plan = DiscoApp::Plan.find(params[:id])
    end

    def plan_params
      params.require(:plan).permit(
        :name, :status, :plan_type, :trial_period_days, :amount,
        :plan_codes_attributes => [:id, :_destroy, :code, :trial_period_days, :amount]
      )
    end

end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
disco_app-0.16.1.pre.sidekiq.pre.6.pre.release app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.0 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.1 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.2 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.3 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.4 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.5 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.6 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.7 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.8 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.9 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.10 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.9.11 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.0 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.1 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.2 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.3 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.4 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.10.5 app/controllers/disco_app/admin/concerns/plans_controller.rb
disco_app-0.11.0 app/controllers/disco_app/admin/concerns/plans_controller.rb