Topic: How to make limit for rows that are included?
I was wondering? what's the right way of doing limit for sub rows (that are included via includes)?
a wider explanation :
class Place < ActiveRecord::Base
class Performance < ActiveRecord::Base
class PerformanceEvent < ActiveRecord::Base
Currently i select this way
@performances = Place.includes(:performances => :performance_events).where('performance_events.starts_at > ? AND performance_events.starts_at < ? AND places.place_category_id = 468', starts_at_gte, starts_at_lte).shuffle
and in view
- loop = 0
- @performances.each do |pl|
- break if loop >= 3
- loop += 1
places.place_category_id = 468 - neet to select only this category of places...
I understant that's it not done the right way... but could have thought only of this.