Class: WcoHosting::DomainsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wco_hosting/domains_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#home

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/wco_hosting/domains_controller.rb', line 4

def create
  @domain = WcoHosting::Domain.new params[:domain].permit!
  authorize! :create, @domain

  if @domain.save
    flash_notice @domain
  else
    flash_alert @domain
  end

  redirect_to action: :index
end

#editObject



17
18
19
20
# File 'app/controllers/wco_hosting/domains_controller.rb', line 17

def edit
  @domain = WcoHosting::Domain.find params[:id]
  authorize! :edit, @domain
end

#indexObject



22
23
24
25
# File 'app/controllers/wco_hosting/domains_controller.rb', line 22

def index
  authorize! :index, WcoHosting::Domain
  @domains = WcoHosting::Domain.all
end

#newObject



28
29
30
31
# File 'app/controllers/wco_hosting/domains_controller.rb', line 28

def new
  @domain = WcoHosting::Domain.new
  authorize! :new, @domain
end

#showObject



33
34
35
36
37
# File 'app/controllers/wco_hosting/domains_controller.rb', line 33

def show
  @domain = WcoHosting::Domain.find params[:id]
  authorize! :show, @domain
  @subdomains = WcoHosting::Appliance.where( domain: @domain.name ).map( &:subdomain )
end

#updateObject



44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/wco_hosting/domains_controller.rb', line 44

def update
  @domain = WcoHosting::Domain.find params[:id]
  authorize! :update, @domain
  if @domain.update_attributes( params[:domain].permit! )
    flash_notice @domain
  else
    flash_alert @domain
  end
  redirect_to action: :index
end