How to find the right object in a Rails controller based on two variables?
- by sscirrus
Hi everyone,
I have a three-table system: Companies, Customers, and Matches. The matches include, for example, private notes that each party makes about the other and some options they can set regarding the other.
I have two sets of views centered around Companies and Customers for each party to look at the other and modify their notes and settings.
# Customers Controller
def show
@customer = Customer.find(params[:customer])
@matchings = @candidate.matchings.find...
@company = Company.find(params[:company])
end
Obviously the @matchings is incomplete. Given that @matchings has fields customer_id and company_id, how do I find the right matching record? Thank you!