The issue here is that where
returns a collection - something similar to an array, just in ActiveRecord - no matter what limit you set on it. To retrieve the information you would use .first
or [0]
since you always only return one object.
But, since you are looking for a specific ContactDescribe
object. Do this instead:
ContactDescribe.find_by(contact_describe_id: 12).borrower_or_lender
Additionally there two things you should improve in your code.
1: Logic should go into the controller or the model. A view is solely here to show objects.
2: What is up with the contact_describe_id
field? Why not call it id
. It seems redundant. Isn't user.id
more convenient than user.user_id
?