Sha256: 9229bfaaa457e4e415067955dd5148c641f1e63eab6969f5c30c15cef57fa140

Contents?: true

Size: 1.6 KB

Versions: 4

Compression:

Stored size: 1.6 KB

Contents

require_dependency "extface/application_controller"

module Extface
  class DevicesController < ApplicationController
    before_action :set_device, only: [:show, :edit, :update, :destroy]

    # GET /devices
    def index
      @devices = extfaceable.extface_devices.load
    end

    # GET /devices/1
    def show
    end

    # GET /devices/new
    def new
      @device = extfaceable.extface_devices.new
      render action: :form
    end

    # GET /devices/1/edit
    def edit
      render action: :form
    end

    # POST /devices
    def create
      @device = extfaceable.extface_devices.new(device_params)
      if @device.save
        redirect_to @device, notice: 'Device was successfully created.'
      else
        render action: :form
      end
    end

    # PATCH/PUT /devices/1
    def update
      if @device.update(device_params)
        redirect_to @device, notice: 'Device was successfully updated.'
      else
        render action: :form
      end
    end

    # DELETE /devices/1
    def destroy
      @device.destroy
      redirect_to devices_url, notice: 'Device was successfully destroyed.'
    end

    def test_page
      set_device
      job = @device.driveable.print_test_page
      render text: job_path(job)
    end

    private
      # Use callbacks to share common setup or constraints between actions.
      def set_device
        @device = extfaceable.extface_devices.find(params[:id])
      end

      # Only allow a trusted parameter "white list" through.
      def device_params
        params.require(:device).permit(:uuid, :name, :driver, :driveable_id, :driveable_type)
      end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
extface-0.0.5 app/controllers/extface/devices_controller.rb
extface-0.0.3 app/controllers/extface/devices_controller.rb
extface-0.0.2 app/controllers/extface/devices_controller.rb
extface-0.0.1 app/controllers/extface/devices_controller.rb