title: ActiveStorage - Get variant URL in model
body: <p>I am in the process of migrating my Rails app from using PaperClip to ActiveStorage. </p>
  
  <p>In one of my models, I had the following method (using paperclip):</p>
  
  <pre><code>class ECard &lt; ActiveRecord
      def thumb_url
          self.attachment.url(:thumb)
      end
  end
  </code></pre>
  
  <p>And in the controller I have:</p>
  
  <pre><code>def by_type
      @e_cards = ECard.where(type_id: params[:type_id]).as_json(:only =&gt; [:id, :name], :methods =&gt; [:thumb_url])
      respond_to do |format|
          format.json { render json: @e_cards }
      end   
  end
  </code></pre>
  
  <p>Now, that I am using ActiveStorage, how to I get the thumbnail url of the attachment from the <code>thumb_url</code> method?</p>
  
  <p><strong>Works</strong>: <code>Rails.application.routes.url_helpers.rails_blob_path(attachment, only_path: true)</code></p>
  
  <p><strong>Does not work</strong>: <code>Rails.application.routes.url_helpers.rails_blob_path(attachment.variant(resize: '200x200'), only_path: true)</code> This throws the error: <code>NoMethodError (undefined method 'signed_id' for #&lt;ActiveStorage::Variant:0x00007fac1960eab0&gt;)</code></p>
  
  <p>How do I achieve this?</p>