I'm working on Ruby on Rails and I'm trying to put a logo.png image in a bootstrap navbar.
so i used this code in app/views/home/_header.html.erb
<nav class="navbar navbar-expand-lg bg-primary " data-bs-theme="dark"> 
  <div class="container-fluid">
   <!-- <a class="navbar-brand" href="#">Estrutecnia</a> -->
 <a class="navbar-brand" href="#">
      <img src="logo.png" alt="Estrutecnia" width="30" height="24">
    </a>


    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled">Disabled</a>
        </li>
      </ul>
      <form class="d-flex" role="search">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>

</nav>

The problem is that the logo doesn't appear, look at the navbar

And the next errors display
Started GET "/logo.png" for 127.0.0.1 at 2023-06-02 20:05:47 -0500

ActionController::RoutingError (No route matches [GET] "/logo.png"):

I tried to put the logo.png file in the root directory that I guess is the folder where the Gemfile and the README.md files are.
I expect that the logo.png appears at the navbar, but a brocken file icon appears at the left side of the navbar, like described in the image above.

Why does my logo not appear in the Bootstrap navbar when using Ruby on Rails?
Images are normally placed in the app/assets/images directory.
When you render a view using the ActionView image_tag helper, Rails automatically populates the image source for you:
image_tag('logo.png')
# => <img src='/assets/icon.png>

This would be the idiomatic way to handle images in Rails, but of course there's nothing that prevents you from including <image src='/assets/icon.png'> in your markup
