How to customize to_json response in Rails 3
问题 I am using respond_with and everything is hooked up right to get data correctly. I want to customize the returned json , xml and foobar formats in a DRY way, but I cannot figure out how to do so using the limited :only and :include . These are great when the data is simple, but with complex finds, they fall short of what I want. Lets say I have a post which has_many images def show @post = Post.find params[:id] respond_with(@post) end I want to include the images with the response so I could