Class: IshManager::ApplianceTmplsController
Instance Method Summary
collapse
#basic_auth, #home, #tinymce
Instance Method Details
#create ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
|
# File 'app/controllers/ish_manager/appliance_tmpls_controller.rb', line 6
def create
@appliance_tmpl = Wco::ApplianceTmpl.new params[:appliance].permit!
authorize! :create, @appliance_tmpl
flag = @appliance_tmpl.save
if flag
flash[:notice] = 'Success.'
redirect_to action: :index
else
flash[:alert] = "Cannot create appliance tmplate: #{@appliance_tmpl.errors.full_messages.join(', ')}."
redirect_to action: :index
end
end
|
#edit ⇒ Object
20
21
22
23
|
# File 'app/controllers/ish_manager/appliance_tmpls_controller.rb', line 20
def edit
@appliance_tmpl = Wco::ApplianceTmpl.find params[:id]
authorize! :edit, @appliance_tmpl
end
|
#index ⇒ Object
25
26
27
28
|
# File 'app/controllers/ish_manager/appliance_tmpls_controller.rb', line 25
def index
authorize! :index, Wco::ApplianceTmpl
@appliance_tmpls = Wco::ApplianceTmpl.all
end
|
#update ⇒ Object
30
31
32
33
34
35
36
37
38
39
40
|
# File 'app/controllers/ish_manager/appliance_tmpls_controller.rb', line 30
def update
@appliance_tmpl = Wco::ApplianceTmpl.find params[:id]
authorize! :update, @appliance_tmpl
flag = @appliance_tmpl.update params[:appliance].permit!
if flag
flash_notice 'success'
else
flash_alert "Cannot update appliance template: #{@appliance_tmpl.errors.full_messages.join(', ')}."
end
redirect_to action: :index
end
|