Pergunta

I have a mongoid model class "Event" embedding many of class "Participant". Participant has a field "email". Now somewhere in the code I get a reference to one specific Event instance named "@event".

How do I now query the participants of ONLY that instance for an participant with email = XYZ?Not all participants in the collection, just the ones of this given instance @event.

Any ideas?

Thx!

Foi útil?

Solução

This should work

@event.participants.where(email: 'XYZ') # this will help you query what ever you want
#or
@event.participants.find_by_email 'XYZ' #this will get exactly one record
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top