title: Why does user image shows up as a broken link in my application?
body: <p>I just started learning Ruby on Rails and I am completely new to this.
  After completing tutorial on rails at Progate, I have decided to make my own app by following the same steps (appropriate for my environment) as I did at Progate.
  Right now I am at the point where I want the User profile image to show on details page and user index page, but I only see broken image link.
  Here is code of my &quot;User Controller&quot;</p>
  <pre><code>class UsersController &lt; ApplicationController
    def index
      @users = User.all
    end
  
    def show
      @user = User.find_by(id: params[:id])
    end
  
    def new
      @user = User.new
    end
  
    def create
      @user = User.new(
        name: params[:name],
        email: params[:email],
        image_name: &quot;default_user.png&quot;
      )
      if @user.save
        flash[:notice] = &quot;You have signed up successfully&quot;
        redirect_to(&quot;/users/#{@user.id}&quot;)
      else
        render(&quot;users/new&quot;)
      end
    end
  
    def edit
      @user = User.find_by(id: params[:id])
    end
  
    def update
      @user = User.find_by(id: params[:id])
      @user.name = params[:name]
      @user.email = params[:email]
  
      # Add code to save the image
      if params[:image]
        @user.image_name = &quot;#{@user.id}.jpg&quot;
        image = params[:image]
        File.binwrite(&quot;public/user_images/#{@user.image_name}&quot;, image.read)
      end
      if @user.save
        flash[:notice] = &quot;Your account has been updated successfully&quot;
        redirect_to(&quot;/users/#{@user.id}&quot;)
      else
        render(&quot;users/edit&quot;)
      end
    end
  
  end
  
  </code></pre>
  <p>I have tried to change image format and permission properties of image (no changes).Here is my index view file -</p>
  <pre><code>&lt;div class=&quot;main users-index&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
      &lt;h1 class=&quot;users-heading&quot;&gt;All Users&lt;/h1&gt;
      &lt;% @users.each do |user| %&gt;
        &lt;div class=&quot;users-index-item&quot;&gt;
          &lt;!-- Paste the HTML here --&gt;
          &lt;div class=&quot;user-left&quot;&gt;
            &lt;!-- Add an &lt;img&gt; tag to display the profile image --&gt;
            &lt;img src=&quot;&lt;%= &quot;/user_images/#{user.image_name}&quot; %&gt;&quot;&gt;
          &lt;/div&gt;
          &lt;div class=&quot;user-right&quot;&gt;
            &lt;%= link_to(user.name, &quot;/users/#{user.id}&quot;) %&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;% end %&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  </code></pre>
  <p>and show view file</p>
  <pre><code>&lt;div class=&quot;main user-show&quot;&gt;
    &lt;div class=&quot;container&quot;&gt;
      &lt;div class=&quot;user&quot;&gt;
        &lt;!-- Add an &lt;img&gt; tag to display the profile image --&gt;
        &lt;img src=&quot;&lt;%= &quot;/user_images/#{@user.image_name}&quot; %&gt;&quot;&gt;
        &lt;h2&gt;&lt;%= @user.name %&gt;&lt;/h2&gt;
        &lt;p&gt;&lt;%= @user.email %&gt;&lt;/p&gt;
        &lt;%= link_to(&quot;Edit&quot;, &quot;/users/#{@user.id}/edit&quot;) %&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  
  </code></pre>
  <p>I have tried re-writing same thing over and over. I have checked my migration db file and everything seems to be fine there.Checked image directory too. SCSS file is fine and it is completely same as the one I've used in tutorial.
  However my SQlite Database Viewer gives me this -
  <a href="https://i.stack.imgur.com/4pIxS.png" rel="nofollow noreferrer">Sqlite db view</a></p>