I have the following ActiveRecord call:
@payment = account.business.payments.find(params[:id])
What is looking through associations for payment with the identifier params[:id] . However, this raises a RecordNotFound exception.
I would like to call exists? to see if a record exists to avoid an exception. Doing Payment.exists?(account.business.payments.find(params[:id])) does not work.
I would like to look only for payments , what belong_to , that business , and not all payments by doing Payment.exists?(:id => params[:id]) . This means that I know that this is a specific business payment.
How can i do this?
Note: account has_one business and business has_many payments .
darksky
source share