Class: Naf::MachineAffinitySlotsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Naf::MachineAffinitySlotsController
- Defined in:
- app/controllers/naf/machine_affinity_slots_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#create ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 33 def create @machine = Naf::Machine.find(params[:machine_affinity_slot][:machine_id]) @slot = Naf::MachineAffinitySlot.new(params[:machine_affinity_slot]) if @slot.save redirect_to(naf.machine_machine_affinity_slot_path(@machine, @slot), notice: "Machine Affinity Slot '#{@slot.affinity_name}' was successfully created.") else render action: "new", machine_id: @machine.id end end |
#destroy ⇒ Object
20 21 22 23 24 25 26 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 20 def destroy @machine = Naf::Machine.find(params[:machine_id]) @slot = Naf::MachineAffinitySlot.find(params[:id]) @slot.destroy flash[:notice] = "Machine Affinity Slot '#{@slot.affinity_name}' was successfully deleted." redirect_to naf.machine_machine_affinity_slots_path(@machine) end |
#edit ⇒ Object
44 45 46 47 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 44 def edit @slot = Naf::MachineAffinitySlot.find(params[:id]) @machine = Naf::Machine.find(params[:machine_id]) end |
#index ⇒ Object
6 7 8 9 10 11 12 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 6 def index @rows = [] if params[:machine_id] @rows = Naf::MachineAffinitySlot.includes(:machine, :affinity).where(machine_id: params[:machine_id]) end render template: 'naf/datatable' end |
#new ⇒ Object
28 29 30 31 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 28 def new @machine = Naf::Machine.find(params[:machine_id]) @slot = Naf::MachineAffinitySlot.new end |
#show ⇒ Object
14 15 16 17 18 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 14 def show @record = Naf::MachineAffinitySlot.find(params[:id]) @machine = Naf::Machine.find(params[:machine_id]) render template: 'naf/record' end |
#update ⇒ Object
49 50 51 52 53 54 55 56 57 58 |
# File 'app/controllers/naf/machine_affinity_slots_controller.rb', line 49 def update @slot = Naf::MachineAffinitySlot.find(params[:id]) @machine = Naf::Machine.find(@slot.machine_id) if @slot.update_attributes(params[:machine_affinity_slot]) redirect_to(naf.machine_machine_affinity_slot_path(@machine, @slot), notice: "Machine Affinity Slot '#{@slot.affinity_name}' was successfully updated") else render action: "edit", machine_id: @machine.id end end |