그래서 db에 대한 쿼리를 수행하고 완전한 객체 배열을 가지고 있습니다.
@attachments = Job.find(1).attachments
이제 객체 배열이 있으므로 다른 db 쿼리를 수행하고 싶지는 않지만 Attachment객체를 기반으로 배열을 필터링 하여 파일 유형이 어디에 있는지 file_type목록을 attachments얻은 'logo'다음 다른 위치 목록을 가질 수 있습니다 attachments. 파일 유형은'image'
이 같은:
@logos = @attachments.where("file_type = ?", 'logo')
@images = @attachments.where("file_type = ?", 'image')
그러나 db 쿼리 대신 메모리에 있습니다.
partition- 여기 예 .