Currently I have a query that DOES order my result set the way I want it, but I would like to limit the number of records returned. I am aware of limit in DataMapper but this has not worked for me because I am limiting each query return rather than the merged return. This is my query:
@activities = current_user.followed_users.activities(:order => [:created_at.desc]) + current_user.followed_centers.activities(:order => [:created_at.desc])
This merges the result set and orders them correctly. However, does anyone know if I can limit the return size of the merged result set? i.e if I said limit => 2… this would get the 2 newest activities either by a user or/and center.
1 Answer