Use try so it doesn't crash
This commit is contained in:
parent
3d9afce424
commit
344f259efd
1 changed files with 1 additions and 1 deletions
|
@ -9,7 +9,7 @@ class BarcodesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@barcode = Barcode.find_by(code: params[:id])
|
@barcode = Barcode.find_by(code: params[:id])
|
||||||
render json: @barcode.product
|
render json: @barcode.try(:product)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
Loading…
Reference in a new issue