title: how to conditionally include associations in a Rails Active Model Serializer v0.8
body: <p>I have used AMS (0.8) with Rails 3.2.19 but one place where I really struggle with them is how to control whether serializers include their associations or not. I obviously use AMS to build JSON 
  Api's. Sometimes a serializer is the leaf or furthest out element and sometimes it's the top level and needs to include associations. My question is what is the best way to do this or is the solution I do below work (or is best solution).</p>
  
  <p>I have seen some of the discussions but I find them very confusing (and version based). It's clear that for Serializer attributes or associations, there is an an include_XXX? method for each and you can return either a truthy or falsey statement here.</p>
  
  <p>Here's my proposed code - it's a winemaker that has many wine_items. Is this how you would do this?</p>
  
  <p>Model Classes:</p>
  
  <pre><code>class WineItem &lt; ActiveRecord::Base
    attr_accessible :name, :winemaker_id
    belongs_to :winemaker
  
  end
  
  class Winemaker &lt; ActiveRecord::Base
    attr_accessible :name
    has_many :wine_items
    attr_accessor :show_items
  end
  </code></pre>
  
  <p>Serializers:</p>
  
  <pre><code>class WinemakerSerializer &lt; ActiveModel::Serializer
    attributes :id, :name
    has_many :wine_items 
  
    def include_wine_items?
      object.show_items
    end
  end
  
  class WineItemSerializer &lt; ActiveModel::Serializer
    attributes :id, :name
  end
  </code></pre>
  
  <p>and in my controller:</p>
  
  <pre><code>class ApiWinemakersController &lt; ApplicationController
    def index
      @winemakers=Winemaker.all
      @winemakers.each { |wm| wm.show_items=true }
      render json: @winemakers, each_serializer: WinemakerSerializer, root: "data"
    end
  end
  </code></pre>