Class: ForemanPackages::SypackagesController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /sypackages POST /sypackages.json



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

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

#destroyObject

DELETE /sypackages/1 DELETE /sypackages/1.json



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

def destroy
  @sypackage = ForemanPackages::Sypackage.find(params[:id])
  @sypackage.destroy

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

#editObject

GET /sypackages/1/edit



36
37
38
# File 'app/controllers/foreman_packages/sypackages_controller.rb', line 36

def edit
  @sypackage = ForemanPackages::Sypackage.find(params[:id])
end

#indexObject

GET /sypackages GET /sypackages.json



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

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

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

#newObject

GET /sypackages/new GET /sypackages/new.json



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

def new
  @sypackage = ForemanPackages::Sypackage.new

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

#showObject

GET /sypackages/1 GET /sypackages/1.json



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

def show
  @sypackage = ForemanPackages::Sypackage.find(params[:id])

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

#updateObject

PUT /sypackages/1 PUT /sypackages/1.json



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

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