Class: Kube::Station::ClustersController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kube/station/clusters_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#default_url_options

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'app/controllers/kube/station/clusters_controller.rb', line 15

def create
  @config = Config.new(config_params)

  if @config.save
    @cluster = @config.clusters.new(cluster_params)
    if @cluster.save
      redirect_to clusters_path
    else
      @config.destroy
      render :new, status: :unprocessable_entity
    end
  else
    @cluster = Cluster.new(cluster_params)
    @cluster.build_config
    @cluster.config.errors.merge!(@config.errors)
    render :new, status: :unprocessable_entity
  end
end

#editObject



34
35
# File 'app/controllers/kube/station/clusters_controller.rb', line 34

def edit
end

#indexObject



6
7
8
# File 'app/controllers/kube/station/clusters_controller.rb', line 6

def index
  @clusters = Cluster.all
end

#newObject



10
11
12
13
# File 'app/controllers/kube/station/clusters_controller.rb', line 10

def new
  @cluster = Cluster.new
  @cluster.build_config
end

#updateObject



37
38
39
40
41
42
43
44
45
# File 'app/controllers/kube/station/clusters_controller.rb', line 37

def update
  config = @cluster.config

  if config.update(config_params) && @cluster.update(cluster_params)
    redirect_to clusters_path
  else
    render :edit, status: :unprocessable_entity
  end
end