tap/app/controllers/barcodes_controller.rb

21 lines
486 B
Ruby
Raw Normal View History

class BarcodesController < ApplicationController
2015-10-07 16:39:06 +02:00
load_and_authorize_resource :product, only: :create
load_and_authorize_resource :barcode, through: :product, only: :create
def create
@barcode.save
2015-09-26 11:57:41 +02:00
redirect_to barcode_products_path, notice: "Barcode successfully linked!"
end
def show
2015-10-07 16:42:05 +02:00
@barcode = Barcode.find_by(code: params[:id])
2015-10-07 16:49:29 +02:00
render json: @barcode.try(:product)
end
private
def barcode_params
params.require(:barcode).permit(:code)
end
end