I have a question regarding JSON APIs - what is the best practice regarding rendering json in response to .json API calls?
As far as I understand there are 3 options:
1) render @my_models_collection which will call to_json on every object and will collect the return into a json array (no customization here except calling :methods => …)
2) override to_json/as_json on the model this would let me customize the json output when controller’s render method calls to_json on the members of the collection I passed to it
3) use template views something like index.json.rb and than map every element of my collection and call to_json on the result. But this is quickly gets ugly and has some performance implications…
I believe I’m missing something and there is a good and clear solution to this.