Rails filtering array of objects by attribute value

前端 未结 5 2030
天涯浪人
天涯浪人 2020-12-12 13:33

So I perform a query to the db and I have a complete array of objects:

@attachments = Job.find(1).attachments

Now that I have an array of o

5条回答
  •  既然无缘
    2020-12-12 13:47

    You can filter using where

    Job.includes(:attachments).where(file_type: ["logo", "image"])
    

提交回复
热议问题