title: How can I get url for paperclip image in to_json
body: <p>I have a model that uses paperclip like this:</p>
  
  <pre><code>has_attached_file :avatar, :styles =&gt; { :large =&gt; "100x100&gt;" , :medium =&gt; "50x50&gt;", :small =&gt; "20x20&gt;" },  :default_url =&gt; '/images/missing-owner_:style.png'
  </code></pre>
  
  <p>I'm exporting this model with to_json method and I want to export the image url so I could use it in javascript.</p>
  
  <p>I know I can access the url like this in the view:</p>
  
  <pre><code>&lt;%= image_tag model.avatar.url(:medium) %&gt;
  </code></pre>
  
  <p>But How can I do the same in the to_json method.</p>
  
  <p>I have some like this:</p>
  
  <pre><code>respond_to do |format|
     render :json =&gt; @model.to_json(:only =&gt; [:id,:name,:homephone,:cellphone])
  end
  </code></pre>