title: How to limit the number of record associations get printed when rendering json in respond_to
body: <p>I've had trouble understanding how this really works. My problem is this</p>
  
  <h2><strong>Stuffs Controller</strong></h2>
  
  <pre><code>  def refresh_stuffs
      id = params[:stuff][:id]
      last_update = params[:stuff][:last_update]
  
      @stuff = Stuff.find(id)
      @stuff.events.where('? &lt; updated_at','2014-06-25 21:57:52') # The updated_at attr is 2014-06-19 22:59:15 
      respond_to do |format|
        format.json {
          render json: @stuff, status: :ok,
          include: {
            events: {except: [:created_at, :updated_at, :visible]}
          },
          except: [:created_at, :updated_at, :user_id]
        }
      end
    end
  </code></pre>
  
  <p>Now rendering works great except for one thing, when I want to render the associations as well it does not let me limit it. Everything I see talks about limiting which columns to show, I want to limit the amount of records that are accessed. Currently even the record I am trying to strip out using the <code>where</code> query above is showing up. How exactly are the associations queried when rendered in json? What can I do to filter it the way I want to?</p>
  
  <p><strong>Example output</strong>: <code>{"id":2, "name": "le name", "events": [{"id": 2, "etc":""}]</code></p>
  
  <p><strong>What I should get with the above example code</strong>: <code>{"id":2, "name": "le name", "events":[]</code></p>