title: How to use :include, :except, :only for hashes from :methods in rails render
body: <p>I need to render the itinerary json but <strong>consolidating all todos</strong> as a single json array nested inside:</p>
  
  <pre><code>render json: @itinerary, include: {
                             places: {
                               only: [:id, :title],
                               include: {
                                 todos: {
                                    only: [:id, :content],
                                    include: :todo_type
                                 },
                                 place_category: {
                                    include: {
                                         todos: {
                                             only: [:id, :content],
                                             include: :todo_type
                                         }
                                    }
                                 },
                                 climate: {
                                     include: {
                                         todos: {
                                             only: [:id, :content],
                                             include: :todo_type
                                         }
                                     }
                                 }
                               }
                             }
                           } 
  </code></pre>
  
  <p>I wish to render all todos together, so that the client doesn't have to do the consolidate all todos, removing duplicates and doing other work on it.</p>
  
  <p>So I created a method <code>consolidated_todos</code> in <code>place</code> model</p>
  
  <pre><code>def considated_todos
    todos = self.todos
    todos += self.place_category.todos
    todos += self.climate.todos
    todos
  end
  </code></pre>
  
  <p>And then changed my render method to the following</p>
  
  <pre><code>render json: @itinerary, include: {
                             places: {
                               only: [:id, :title],
                               include: :place_category,
                               methods: [:consolidated_todos],
                             }
                           }
  </code></pre>
  
  <blockquote>
    <p>How do I add <code>:include</code> <em>(:todo_type, etc.,)</em>, <code>:only</code> <em>(:id, :content, etc.,)</em> and <code>:except</code> <strong>for hashes returned from <code>:methods</code></strong>?</p>
  </blockquote>
  
  <p>I need to do something like  <code>methods: [ consolidated_todos: { include: :todo_type } ]</code>.</p>
  
  <hr>
  
  <p><strong>EDIT</strong>:</p>
  
  <p>This question is <strong>NOT</strong> about</p>
  
  <ol>
  <li>how to serialize resources</li>
  <li>how to include nested resources</li>
  <li>using jbuilder / Active Model Serializer / RABL / similar libs to do (1) or (2)</li>
  </ol>
  
  <p>but is specifically about using <code>include</code> for hashes returned from <code>:methods</code> or an equivalent short workaround <em>(instead of using <code>as_json</code>)</em> for the same</p>