title: rails - Displaying image in view after uploading a file via Active Storage
body: <p>I have a project that is on rails <code>5.1.2</code> and I am trying to implement Active Storage on it, following couple of tutorials online I am able to setup the Active Storage and I can see the data being saved inside the <code>active_storage_blobs</code> and <code>active_storage_attachments</code> table.</p>
  
  <ol>
  <li><a href="https://rubyinrails.com/2017/07/21/rails-introduces-active-storage-for-file-uploads/" rel="noreferrer">Tutorial 1</a></li>
  <li><a href="https://afreshcup.com/home/2017/07/23/activestorage-samples" rel="noreferrer">Tutorial 2</a></li>
  </ol>
  
  <p>I also confirmed by running <code>user.avatar.attached?</code> and in response I got true so things are working.</p>
  
  <p>What I am having problem with is displaying an image in view, I have tried</p>
  
  <pre><code>&lt;%= image_tag(url_for(user.avatar)) %&gt;
  </code></pre>
  
  <blockquote>
    <p>NoMethodError: undefined method `active_storage_attachment_path'</p>
  </blockquote>
  
  <p><strong>What I have done to setup Active Storage</strong></p>
  
  <p>Ran the install command</p>
  
  <pre><code>rails active_storage:install
  </code></pre>
  
  <p>This gave error <em>Don't know how to build task 'active_storage:install'</em></p>
  
  <p>but the following command worked</p>
  
  <pre><code>rails activestorage:install
  </code></pre>
  
  <p>I have added <code>gem 'activestorage'</code> inside <code>gemfile</code></p>
  
  <p>This is what I have inside my <code>storage_services.yml</code></p>
  
  <pre><code>test:
    service: Disk
    root: &lt;%= Rails.root.join("tmp/storage") %&gt;
  
  local:
    service: Disk
    root: &lt;%= Rails.root.join("storage") %&gt;
  </code></pre>
  
  <p>Inside my <code>development.rb</code> I have added</p>
  
  <pre><code>config.active_storage.service = :local
  </code></pre>
  
  <p>Inside my <code>User</code> model I have added <code>has_one_attached :avatar</code></p>
  
  <p>Inside the controller on update I added the attachment code</p>
  
  <pre><code>user.avatar.attach(params[:user][:avatar])
  </code></pre>
  
  <ol>
  <li>I can see the image being added in database,  </li>
  <li>I can see the image being saved in the storage directory on root</li>
  </ol>
  
  <p>Yet I am not able to display it,</p>
  
  <p>What am I missing here? What do I need to do to get the image to display in the view? Why am i getting this error</p>
  
  <blockquote>
    <p>NoMethodError: undefined method `active_storage_attachment_path'</p>
  </blockquote>