Skip to content

Commit

Permalink
don't try to limit donation to customer if params[:cid] is blank - ot…
Browse files Browse the repository at this point in the history
…herwise was causing 404 error due to AR::RecordNotFound exception when trying to call #find with an empty string
  • Loading branch information
armandofox committed Jan 24, 2024
1 parent ace396a commit d3c644e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion app/controllers/donations_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def index
includes(:order,:customer,:account_code).
where.not(:customer_id => Customer.walkup_customer.id).
order(:sold_on)
if params[:use_cid] # cust id will be embedded in route in autocomplete field
if (params[:use_cid] && !params[:cid].blank?) # cust id will be embedded in route in autocomplete field
cid = if params[:cid] =~ /^\d+$/ then params[:cid] else Customer.id_from_route(params[:cid]) end
@donations = @donations.where(:customer_id => cid)
@full_name = Customer.find(cid).full_name
Expand Down

0 comments on commit d3c644e

Please sign in to comment.