Reputation: 34053
How could I get a bird's view of a returned collection regarding structure and collection types? I find it hard to iterate through a collection with so many objects that I cannot see the structure of the nesting.
When executing Post.all.group_by {|post| post.category}
a nested Hash
of some sort seem to be returned. Post
belongs_to Category
.
Upvotes: 0
Views: 61
Reputation: 5740
If you want to use iteration all you have to do is this:
Category.all.each do |category|
category.posts.each do |post|
# your logic
end
end
Upvotes: 1
Reputation: 385
You can use the awesome_print gem for great formatting.
https://github.com/michaeldv/awesome_print
Upvotes: 4