Class: WcoHosting::FilesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/wco_hosting/files_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
16
# File 'app/controllers/wco_hosting/files_controller.rb', line 4

def create
  @file = WcoHosting::File.new params[:file].permit!
  authorize! :create, @file

  flag = @file.save
  if flag
    flash[:notice] = 'Success.'
    redirect_to action: :index
  else
    flash[:alert] = "Cannot create file: #{@file.errors.full_messages.join(', ')}."
    render action: :index
  end
end

#editObject



18
19
20
21
22
23
# File 'app/controllers/wco_hosting/files_controller.rb', line 18

def edit
  @file = WcoHosting::File.find params[:id]
  authorize! :edit, @file

  @serverhost = @file.serverhost
end

#indexObject



25
26
27
28
29
# File 'app/controllers/wco_hosting/files_controller.rb', line 25

def index
  authorize! :index, WcoHosting::File
  @files = WcoHosting::File.all
  @new_file = WcoHosting::File.new
end

#newObject



31
32
33
34
# File 'app/controllers/wco_hosting/files_controller.rb', line 31

def new
  authorize! :index, WcoHosting::File
  @new_file = WcoHosting::File.new
end

#showObject



36
37
38
39
# File 'app/controllers/wco_hosting/files_controller.rb', line 36

def show
  @file = WcoHosting::File.find params[:id]
  authorize! :show, @file
end

#updateObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/wco_hosting/files_controller.rb', line 41

def update
  @file = WcoHosting::File.find params[:id]
  authorize! :update, @file
  if @file.update_attributes( params[:file].permit! )
    flash_notice @file
  else
    flash_alert @file
  end
  redirect_to request.referrer
end