Class: Admin::CouponsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /coupons



24
25
26
27
28
29
30
31
32
# File 'app/controllers/tang/admin/coupons_controller.rb', line 24

def create
  @coupon = Coupon.new(coupon_params)

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

#destroyObject

DELETE /coupons/1



35
36
37
38
# File 'app/controllers/tang/admin/coupons_controller.rb', line 35

def destroy
  @coupon.destroy
  redirect_to admin_coupons_url, notice: 'Coupon was successfully destroyed.'
end

#indexObject

GET /coupons



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

def index
  @coupons = Coupon.all.
                    paginate(page: params[:page]).
                    order(:stripe_id)
end

#newObject

GET /coupons/new



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

def new
  @coupon = Coupon.new
end

#showObject

GET /coupons/1



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

def show
end