I have a simple messaging system in Rails with a Message table for the original information and a MessageCopy table for each recipient's information.
Message includes job_id, subject, body, and author_id.
MessageCopy includes recipient_id and message_id.
I am trying to isolate a specific set of messages. I need the recipient to see all message_copies that are 1. addressed to the recipient, and 2. belong to any message with message.job_id = @job.id. Something like?
@jobmessages = Message.find_all_by_job_id(job.id)
@messages = MessageCopy.find_all_by_recipient_id_and_message_id(current_user.id, @jobmessages.id)
How can you do a find_all_by when one of the criteria is a hash like @jobmessages?
Thanks!