Just an FIY - this was my solution:

[code]
   def self.active_record_to_array_of_hashes(array_collection, 
sub_collection_names=[])
     hashed_collection = []
     array_collection.each do |obj|
       tmp_hash = ActiveSupport::JSON.decode(obj.to_json)

       #### hashify specified model association
       sub_collection_names.each do |name|
         if(obj.class.reflections.keys.include?(name))
           tmp_hash[name] = 
ActiveSupport::JSON.decode(obj.send(name).to_json)
         end
       end
       hashed_collection << tmp_hash
     end
     return hashed_collection
   end
[/code]

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/954fac83bc843ff6418a3a58a965bf66%40ruby-forum.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to