Sha256: 0cf0c80c6dc0c0e47a39eb25da8b19d0981ef6512fb587ae37b85366a766fd23

Contents?: true

Size: 876 Bytes

Versions: 8

Compression:

Stored size: 876 Bytes

Contents

class InventoriesController < ApplicationController
  before_action :set_inventory, only: [:show, :edit, :update, :destroy]
  before_action :check_policy, only: [:index, :new, :create]

  # GET /inventories
  # GET /inventories.json
  def index
    @inventories = Inventory.page(params[:page])

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

  # GET /inventories/1
  # GET /inventories/1.json
  def show
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @inventory }
    end
  end

  private
  def set_inventory
    @inventory = Inventory.find(params[:id])
    authorize @inventory
  end

  def check_policy
    authorize Inventory
  end

  def inventory_params
    params.require(:inventory).permit(
      :item_id, :inventory_id, :note
    )
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
enju_inventory-0.3.1 app/controllers/inventories_controller.rb
enju_inventory-0.4.0.rc.1 app/controllers/inventories_controller.rb
enju_inventory-0.3.0 app/controllers/inventories_controller.rb
enju_inventory-0.3.0.beta.1 app/controllers/inventories_controller.rb
enju_inventory-0.2.0 app/controllers/inventories_controller.rb
enju_inventory-0.2.0.beta.3 app/controllers/inventories_controller.rb
enju_inventory-0.2.0.beta.2 app/controllers/inventories_controller.rb
enju_inventory-0.2.0.beta.1 app/controllers/inventories_controller.rb