Answer by tokland for Summing the size/count of associations for multiple...
Equivalent, but functional and idiomatic:def total_leg_count active_flights_within_timeframe.includes(:legs).map { |fl| fl.legs.size }.sumendThis pure SQL query should be equivalent and more...
View ArticleSumming the size/count of associations for multiple records
I'm working on a plain Ruby class within a Rails application.For the total_leg_count method---is that the best way to go about achieving what I want? I feel like there's potentially a better way.class...
View Article
More Pages to Explore .....