Class: WcoHosting::EnvironmentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wco_hosting/environments_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/environments_controller.rb', line 4

def create
  @environment = WcoHosting::Environment.new params[:environment].permit!
  authorize! :create, @environment

  if @environment.save
    flash_notice 'success'
  else
    flash_alert @environment
  end

  redirect_to action: :index
end

#editObject



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

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

#indexObject



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

def index
  authorize! :index, WcoHosting::Environment
  @environments = WcoHosting::Environment.all
end

#newObject



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

def new
  authorize! :new, WcoHosting::Environment
  @environment = WcoHosting::Environment.new
end

#showObject



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

def show
  @environment = WcoHosting::Environment.find params[:id]
  authorize! :show, @environment
  @subenvironments = WcoHosting::Appliance.where( environment: @environment.name ).map( &:subenvironment )
end

#updateObject



39
40
41
42
43
44
45
46
47
48
# File 'app/controllers/wco_hosting/environments_controller.rb', line 39

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