Class: CpOraclecloud::SshKeysController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/cp_oraclecloud/ssh_keys_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

def show authorize @ssh_key end



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 19

def create
	authorize SshKey
  @ssh_key = SshKey.new(ssh_key_params)

  if @ssh_key.valid?
  	ssh_key = SshKey.create(ssh_key_params)
    flash[:notice] = "SSH Key has been created."
    redirect_to cp_oraclecloud_admin_path
  else
 	  flash.now[:alert] = "SSH Key has not been created."
    render "new"
  end
end

#destroyObject



37
38
39
40
41
42
43
44
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 37

def destroy
	authorize @ssh_key
	#@ssh_key.destroy
	SshKey.delete(@ssh_key.id)
 	flash[:notice] = "SSH Key has been deleted."

 	redirect_to cp_oraclecloud_admin_path
end

#editObject



33
34
35
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 33

def edit
	#authorize @ssh_key
end

#indexObject



5
6
7
8
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 5

def index
	authorize SshKey
	@ssh_keys = SshKey.all
end

#newObject



10
11
12
13
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 10

def new
	authorize SshKey
	@ssh_key = CpOraclecloud::SshKey.new
end

#updateObject



46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/cp_oraclecloud/ssh_keys_controller.rb', line 46

def update
	authorize @ssh_key
	if @ssh_key.update(ssh_key_params)
		flash[:notice] = "SSH Key has been updated."
		redirect_to cp_oraclecloud_admin_path
	else
		flash.now[:alert] = "SSH Key has not been updated."
		render "edit"
	end
end