Class: ForemanPackages::SyattachmentsController

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

Instance Method Summary collapse

Instance Method Details

#createObject

POST /syattachments POST /syattachments.json



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'app/controllers/foreman_packages/syattachments_controller.rb', line 45

def create
  @syattachment = ForemanPackages::Syattachment.new(params[:foreman_packages_syattachment])

  if params[:foreman_packages_syattachment][:link].present?
    @syattachment.filename = params[:foreman_packages_syattachment][:link].original_filename
  end
  respond_to do |format|
    if @syattachment.save
      #format.html { redirect_to @syattachment, notice: 'Sypackagemodel was successfully created.' }
      #format.json { render json: @syattachment, status: :created, location: @syattachment }
      format.html { redirect_to @syattachment.foreman_packages_sypackagemodel }
      format.json { head :no_content }
    else
      format.html { render action: "new" }
      format.json { render json: @syattachment.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /syattachments/1 DELETE /syattachments/1.json



84
85
86
87
88
89
90
91
92
# File 'app/controllers/foreman_packages/syattachments_controller.rb', line 84

def destroy
  @syattachment = ForemanPackages::Syattachment.find(params[:id])
  @syattachment.destroy

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

#editObject

GET /syattachments/1/edit



39
40
41
# File 'app/controllers/foreman_packages/syattachments_controller.rb', line 39

def edit
  @syattachment = ForemanPackages::Syattachment.find(params[:id])
end

#indexObject

GET /syattachments GET /syattachments.json



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

def index
  @syattachments = ForemanPackages::Syattachment.all

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

#newObject

GET /syattachments/new GET /syattachments/new.json



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/foreman_packages/syattachments_controller.rb', line 26

def new
  #packagemodel = ForemanPackages::Sypackagemodel.find(params[:sypackagemodel_id])
  #@syattachment = attachmentmodel.syattachments.new
  #
  packagemodel = ForemanPackages::Sypackagemodel.find(params[:sypackagemodel_id])
  @syattachment = packagemodel.syattachments.new
  respond_to do |format|
    format.html # new.html.erb
    format.json { render json: @syattachment }
  end
end

#showObject

GET /syattachments/1 GET /syattachments/1.json



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

def show
  @syattachment = ForemanPackages::Syattachment.find(params[:id])

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

#updateObject

PUT /syattachments/1 PUT /syattachments/1.json



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'app/controllers/foreman_packages/syattachments_controller.rb', line 66

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