Not sure of the best way to do this - I have a where clause that I need to use two models In order to get list results for an autocomplete. I have a 'Membership' model that contains either a 'User' reference or a 'Member' reference (either the user_id is nil or the member_id is nil, but not both).
I need to list out both the User names AND the Member names for the current_user, plucking the user_id if not nil or the member_id, respectively.
I tried to add an && to the where clause but it doesn't seem to be working
User.where(id: current_user.memberships.pluck(&:user_id)) && Member.where(id: current_user.memberships.pluck(&:member_id)
How can I make this work and make it Railsy?
Aucun commentaire:
Enregistrer un commentaire