Class: Admin::Externals::CompaniesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/admin/externals/companies_controller.rb

Overview

typed: ignore

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @company = klass.new company_params

  if @company.save
    redirect_to admin_externals_company_path(@company)
  else
    flash[:error] = @company.errors.full_messages.to_sentence
    render 'new'
  end
end

#destroyObject



54
55
56
57
58
59
60
# File 'app/controllers/admin/externals/companies_controller.rb', line 54

def destroy
  if @company.destroy
    redirect_to admin_externals_companies_path, notice: "#{@company.name} deleted successfully"
  else
    redirect_back fallback_location: back_fallback_location, alert: @company.errors.full_messages.to_sentence
  end
end

#editObject



42
43
# File 'app/controllers/admin/externals/companies_controller.rb', line 42

def edit
end

#indexObject



15
16
17
18
19
20
21
22
# File 'app/controllers/admin/externals/companies_controller.rb', line 15

def index
  set_meta_tags title: 'Corporate Company Partners'
  @grid = ::Admin::Externals::CompaniesGrid.new(params[:admin_externals_companies_grid]) do |scope|
    scope.page(params[:page]).per(10)
  end
  etag = CityHash.hash32([self.class.to_s, @grid.assets.cache_key, params])
  return unless stale?(etag: etag)
end

#newObject



24
25
26
# File 'app/controllers/admin/externals/companies_controller.rb', line 24

def new
  @company = klass.new
end

#send_verification_notificationObject



7
8
9
10
11
12
13
# File 'app/controllers/admin/externals/companies_controller.rb', line 7

def send_verification_notification
  @company.unverified_users.find_each do |user|
    user.send_confirmation_instructions
  end

  redirect_to admin_externals_companies_path, notice: 'Notification has been sent successfully'
end

#showObject



39
40
# File 'app/controllers/admin/externals/companies_controller.rb', line 39

def show
end

#updateObject



45
46
47
48
49
50
51
52
# File 'app/controllers/admin/externals/companies_controller.rb', line 45

def update
  if @company.update company_params
    redirect_to admin_externals_company_path(@company)
  else
    flash[:error] = @company.errors.full_messages.to_sentence
    render 'edit'
  end
end