Use try so it doesn't crash

This commit is contained in:
benji 2015-10-07 16:49:29 +02:00
parent 3d9afce424
commit 344f259efd

View file

@ -9,7 +9,7 @@ class BarcodesController < ApplicationController
def show
@barcode = Barcode.find_by(code: params[:id])
render json: @barcode.product
render json: @barcode.try(:product)
end
private