Class: Admin::PlansController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/tang/admin/plans_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /plans



28
29
30
31
32
33
34
35
36
# File 'app/controllers/tang/admin/plans_controller.rb', line 28

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

#destroyObject

DELETE /plans/1



48
49
50
51
# File 'app/controllers/tang/admin/plans_controller.rb', line 48

def destroy
  @plan.destroy
  redirect_to admin_plans_url, notice: 'Plan was successfully destroyed.'
end

#editObject

GET /plans/1/edit



24
25
# File 'app/controllers/tang/admin/plans_controller.rb', line 24

def edit
end

#indexObject

GET /plans



8
9
10
11
12
# File 'app/controllers/tang/admin/plans_controller.rb', line 8

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

#newObject

GET /plans/new



19
20
21
# File 'app/controllers/tang/admin/plans_controller.rb', line 19

def new
  @plan = Plan.new
end

#showObject

GET /plans/1



15
16
# File 'app/controllers/tang/admin/plans_controller.rb', line 15

def show
end

#updateObject

PATCH/PUT /plans/1



39
40
41
42
43
44
45
# File 'app/controllers/tang/admin/plans_controller.rb', line 39

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