This week's book giveaway is in the Performance forum.
We're giving away four copies of The Java Performance Companion and have Charlie Hunt, Monica Beckwith, Poonam Parhar, & Bengt Rutisson on-line!
See this thread for details.
Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Creating nested hash from nested active record results

 
Eric Hermann
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Hello,
I'm trying to find a very abstract and "one size fits all" for converting nested active record results to nested hashes. It's easy, to do one level deep as such:



But, when I try to add another collection to the mix, it completely borks and the results_to_hash only returns an empty hash IE:



Ultimately, I'd like it to be smart enough to detect if a model object contains a collection (IE: object.class.reflect_on_all_associations), and automatically convert those to hashes.


Any ideas?

Thanks,
Eric
 
Eric Hermann
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just an FIY - this was my solution:

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic