title: Serializing a custom attribute
body: <p>I am using the <code>Active Model Serializer</code> gem for my application. Now I have this situation where a user can have an avatar which is just the ID of a medium.</p>
  
  <p>I have the avatar info saved into Redis. So currently what I do to show the avatar at all in the serialized JSON, is this:</p>
  
  <p>class UserSerializer &lt; ActiveModel::Serializer
      include Avatar</p>
  
  <pre><code>attributes :id,
             :name,
             :email,
             :role,
             :avatar
  
  def avatar
      Medium.find(self.current_avatar)[0]
  end
  
  #has_one :avatar, serializer: AvatarSerializer
  
  has_many :media, :comments
  
  url :user
  </code></pre>
  
  <p>end</p>
  
  <p>I query Redis to know what medium to look for in the database, and then use the result in the <code>:avatar</code> key.</p>
  
  <p>Down in the code there is also a line commented out, that was the only way I found on the <a href="https://github.com/rails-api/active_model_serializers/" rel="nofollow">https://github.com/rails-api/active_model_serializers/</a> page about using a custom serializer for something inside of serializer.</p>
  
  <p>So to get to my problem. Right now the <code>:avatar</code> comes just like it is in the database but I want it to be serialized before I serve it as JSON. 
  How can I do that in this case?</p>