Class: IshManager::ServerhostsController
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/serverhosts_controller.rb', line 6
def create
@serverhost = Wco::Serverhost.new params[:serverhost].permit!
authorize! :create, @serverhost
flag = @serverhost.save
if flag
flash[:notice] = 'Success.'
redirect_to action: :index
else
flash[:alert] = "Cannot create serverhost: #{@serverhost.errors.full_messages.join(', ')}."
render action: :index
end
end
|
#edit ⇒ Object
20
21
22
23
|
# File 'app/controllers/ish_manager/serverhosts_controller.rb', line 20
def edit
@serverhost = Wco::Serverhost.find params[:id]
authorize! :edit, @serverhost
end
|
#index ⇒ Object
25
26
27
28
29
|
# File 'app/controllers/ish_manager/serverhosts_controller.rb', line 25
def index
authorize! :index, Wco::Serverhost
@serverhosts = Wco::Serverhost.all
@new_serverhost = Wco::Serverhost.new
end
|
#show ⇒ Object
31
32
33
34
|
# File 'app/controllers/ish_manager/serverhosts_controller.rb', line 31
def show
@serverhost = Wco::Serverhost.find params[:id]
authorize! :show, @serverhost
end
|
#update ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'app/controllers/ish_manager/serverhosts_controller.rb', line 36
def update
@serverhost = Wco::Serverhost.find params[:id]
authorize! :update, @serverhost
flag = @serverhost.update_attributes params[:serverhost].permit!
if flag
flash[:notice] = "Success."
redirect_to action: :index
else
flash[:alert] = "Cannot update serverhost: #{@serverhost.errors.full_messages.join(', ')}."
render action: :edit
end
end
|