Class: RamWorkloadsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/ram_workloads_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate_admin!, #authenticate_user!, #forbidden_response, #json_request?, #record_not_found, #unauthorized_response

Instance Method Details

#createObject


27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/ram_workloads_controller.rb', line 27

def create
  @ram_workload = RamWorkload.new
  @ram_workload.update_attributes(ram_workload_params)
  @ram_workload.user = current_user
  respond_to do |format|
    if @ram_workload.save!
      format.html {redirect_to @ram_workload, notice: 'RAM Workload was successfully created!'}
      format.json {render json: @ram_workload, status: :created}
    else
      format.html
      format.json {render json: @ram_workload.errors, status: :unprocessable_entity}
    end
  end
end

#destroyObject


54
55
56
57
58
59
60
# File 'app/controllers/ram_workloads_controller.rb', line 54

def destroy
  @ram_workload.destroy
  respond_to do |format|
    format.html {redirect_to :back, notice: 'RAM Workload was successfully destroyed.' }
    format.json {head :no_content, status: :deleted}
  end
end

#indexObject


11
12
13
14
15
16
17
# File 'app/controllers/ram_workloads_controller.rb', line 11

def index
  @ram_workloads = current_user.ram_workloads.page(params[:page])
  respond_to do |format|
    format.html
    format.json {render json: @ram_workloads, status: :ok}
  end
end

#newObject


19
20
21
22
23
24
25
# File 'app/controllers/ram_workloads_controller.rb', line 19

def new
 @ram_workload = if params[:copy]
   RamWorkload.find(params[:copy]).deep_dup
 else
   RamWorkload.new
 end
end

#ram_workload_paramsObject (private)


68
69
70
# File 'app/controllers/ram_workloads_controller.rb', line 68

def ram_workload_params
  params.require(:ram_workload).permit(:ingredient_id, :ram_mb_required, :ram_mb_required_user_capacity, :ram_mb_growth_per_user)
end

#set_ram_workloadObject (private)


64
65
66
# File 'app/controllers/ram_workloads_controller.rb', line 64

def set_ram_workload
  @ram_workload = current_user.ram_workloads.find(params[:id])
end

#showObject


4
5
6
7
8
9
# File 'app/controllers/ram_workloads_controller.rb', line 4

def show
  respond_to do |format|
    format.html
    format.json {render json: @ram_workload, status: :ok}
  end
end

#updateObject


42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/ram_workloads_controller.rb', line 42

def update
  respond_to do |format|
    if @ram_workload.update(ram_workload_params)
      format.html
      format.json {render json: @ram_workload, status: :ok}
    else
      format.html
      format.json {render json: @ram_workload.errors, status: :unprocessable_entity}
    end
  end
end