Posts [ 1 ]

Topic: Get sub-result of mass-query

Hi,I´m optimizing Ruby project. I found out that major problem of the project is that there is a lot of single sql queries in loop so I load them at once with array of type_arrays..items = Item.find_by_id(type_array) #I can get several items for one type, there are hundrer of types, I want load them at once

My project became faster but now I found such place where I want to load such items at once but group them or select them by idHow can I select such result?subitems = items.select ( |i| i[":type]==some_type) #this doesn´t work, I need something similar