Associations and to_json on collections of objects

ActiveRecord’s Serialization module does provide to_json method. It allows include associations when dumping to JSON, but it works only for single objects. If You want to run it against collection, returned by find :all You will get: >> Model.all.to_json :include =>:association TypeError: wrong argument type Hash (expected Data) from (irb):13:in `to_json’ from (irb):13 If You …