Class: DealRedemptions::Admin::CompaniesController

Inherits:
DealRedemptions::ApplicationController show all
Defined in:
app/controllers/deal_redemptions/admin/companies_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 19

def create
  @company = DealRedemptions::Company.new(company_params)

  if @company.save
    redirect_to admin_companies_path, notice: 'Company successfully added.'
  else
    render :new
  end
end

#destroyObject



40
41
42
43
44
45
46
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 40

def destroy
  if @company.destroy
    redirect_to admin_companies_path, notice: 'Company was successfully removed.'
  else
    render :edit, notice: 'Company was not removed. Try again'
  end
end

#editObject



29
30
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 29

def edit
end

#indexObject



11
12
13
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 11

def index
  @companies = DealRedemptions::Company.all_by_name.page(params[:page])
end

#newObject



15
16
17
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 15

def new
  @company = DealRedemptions::Company.new
end

#updateObject



32
33
34
35
36
37
38
# File 'app/controllers/deal_redemptions/admin/companies_controller.rb', line 32

def update
  if @company.update(company_params)
    redirect_to admin_companies_path, notice: 'Company was successfully updated.'
  else
    render :edit
  end
end