Created
January 14, 2015 13:25
-
-
Save cassioscabral/431d804538d1c046ef05 to your computer and use it in GitHub Desktop.
Getting all posts limited
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@all_posts = [] | |
@categories = Category.includes(:posts) | |
@categories.each do |category| | |
@all_posts.concat(category.posts.limit(3)) | |
end | |
# precisando acessar uma category de um post == post.category | |
@all_posts.each do |post| | |
post.category | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment