How would I optimize the following code?

def posts_for_30_blogs
   blogs = Blog.limit(30)
   blogs.flat_map do |blog|
     blog.posts.to_a
   end
end

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/96e5eb5a6ce184f7b519c4c43f9c358a%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

Discussion Posts

Follow ups

Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 1 of 3 | next ›
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedJun 8, '16 at 1:06a
activeJun 8, '16 at 4:31a
posts3
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Hem Chan: 2 posts Greg Navis: 1 post

People

Translate

site design / logo © 2021 Grokbase