2015-09-25 12:24:32 +00:00
|
|
|
class BarcodesController < ApplicationController
|
2015-10-07 13:34:22 +00:00
|
|
|
load_and_authorize_resource :product
|
2015-10-07 13:55:47 +00:00
|
|
|
load_and_authorize_resource :barcode, through: :product, shallow: true
|
2015-09-25 12:24:32 +00:00
|
|
|
|
|
|
|
def create
|
|
|
|
@barcode.save
|
2015-09-26 09:57:41 +00:00
|
|
|
redirect_to barcode_products_path, notice: "Barcode successfully linked!"
|
2015-09-25 12:24:32 +00:00
|
|
|
end
|
|
|
|
|
2015-09-28 19:51:40 +00:00
|
|
|
def show
|
|
|
|
render json: @barcode.product
|
|
|
|
end
|
|
|
|
|
2015-09-25 12:24:32 +00:00
|
|
|
private
|
|
|
|
|
|
|
|
def barcode_params
|
|
|
|
params.require(:barcode).permit(:code)
|
|
|
|
end
|
|
|
|
end
|