Class: ForemanPackages::PackagesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/foreman_packages/packages_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /packages POST /packages.json



43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'app/controllers/foreman_packages/packages_controller.rb', line 43

def create
  @package = ForemanPackages::Package.new(params[:package])
  @package.filename = params[:package][:filename].original_filename
  respond_to do |format|
    if @package.save
      format.html { redirect_to @package, notice: 'package was successfully created.' }
      format.json { render json: @package, status: :created, location: @package }
    else
      format.html { render action: "new" }
      format.json { render json: @package.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /packages/1 DELETE /packages/1.json



75
76
77
78
79
80
81
82
83
# File 'app/controllers/foreman_packages/packages_controller.rb', line 75

def destroy
  @package = ForemanPackages::Package.find(params[:id])
  @package.destroy

  respond_to do |format|
    format.html { redirect_to packages_url }
    format.json { head :no_content }
  end
end

#editObject

GET /packages/1/edit



37
38
39
# File 'app/controllers/foreman_packages/packages_controller.rb', line 37

def edit
  @package = ForemanPackages::Package.find(params[:id])
end

#indexObject

GET /packages GET /packages.json



5
6
7
8
9
10
11
12
# File 'app/controllers/foreman_packages/packages_controller.rb', line 5

def index
  @packages = ForemanPackages::Package.all.paginate(:page => params[:page])

  respond_to do |format|
    format.html # index.html.erb
    format.json { render json: @packages }
  end
end

#newObject

GET /packages/new GET /packages/new.json



27
28
29
30
31
32
33
34
# File 'app/controllers/foreman_packages/packages_controller.rb', line 27

def new
  @package = ForemanPackages::Package.new

  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @package }
  end
end

#showObject

GET /packages/1 GET /packages/1.json



16
17
18
19
20
21
22
23
# File 'app/controllers/foreman_packages/packages_controller.rb', line 16

def show
  @package = ForemanPackages::Package.find(params[:id])

  respond_to do |format|
    format.html # show.html.erb
    format.json { render json: @package }
  end
end

#updateObject

PUT /packages/1 PUT /packages/1.json



59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'app/controllers/foreman_packages/packages_controller.rb', line 59

def update
  @package = ForemanPackages::Package.find(params[:id])
  @package.filename = params[:package][:filename].original_filename
  respond_to do |format|
    if @package.update_attributes(params[:package])
      format.html { redirect_to @package, notice: 'package was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @package.errors, status: :unprocessable_entity }
    end
  end
end