行,col-md-4 添加新的 post

Row, col-md-4 adding a new post

我开始学习 ruby,我想创建一个相册页面,您可以在其中添加 post 图片。我在添加未对齐的 post 时遇到问题,例如 bootstrap 专辑示例:https://getbootstrap.com/docs/4.5/examples/album/ 看看我做了什么https://iv.pl/image/bootstrap.Gt2w3RT

<!DOCTYPE html>
<html>
  <head>
    <title>AlbumSite</title>
    <%= csrf_meta_tags %>

    <link rel="canonical" href="https://getbootstrap.com/docs/4.5/examples/album/">

    <%= stylesheet_link_tag    'https://stackpath.bootstrapcdn.com/bootstrap/4.5.2/css/bootstrap.min.css' %>
 <%= stylesheet_link_tag    'application', media: 'all' %>
<%= javascript_include_tag 'application' %>


  </head>

  <body>

  <section class="jumbotron text-center">
    <div class="container">
      <h1>Simple album</h1>
      <p class="lead text-muted">Something short and leading about the collection below—its contents, the creator, etc. Make it short and sweet, but not too short so folks don’t simply skip over it entirely.</p>
      <p>
        <a href="<%= new_post_path %>" class="btn btn-primary my-2">Add a new album</a>
        <a href="<%= home_path %>" class="btn btn-secondary my-2 ">The first page</a>
      </p>
    </div>
  </section>

<div class="postsSection bg-light">
    <div class="container col-md-4" >
        <div class="postBox">
        <%= yield %>
        </div>
        </div>
</div>

</main>

<footer class="text-muted">
  <div class="container">
    <p class="float-right">
      <a href="#">Back to top</a>
    </p>
    <p>Album example is &copy; Bootstrap, but please download and customize it for yourself!</p>
    <p>New to Bootstrap? <a href="https://getbootstrap.com/">Visit the homepage</a> or read our <a href="/docs/4.5/getting-started/introduction/">getting started guide</a>.</p>
  </div>
</footer>

  </body>
</html>

<% @posts.each do |post| %>   <!--  no %= because this isn an output, tylko przy pokazywaniu zmiennych tego sie uzywa -->

      <div class="row">
        
          <div class="card mb-4 shadow-p">
            <svg class="bd-placeholder-img card-img-top" width="100%" height="225" xmlns="http://www.w3.org/2000/svg" preserveAspectRatio="xMidYMid slice" focusable="false" role="img" aria-label="Placeholder: Thumbnail"><title>Placeholder</title><rect width="100%" height="100%" fill="#55595c"/><text x="50%" y="50%" fill="#eceeef" dy=".3em">Thumbnail</text></svg>
            <div class="card-body">
              <p class="card-text"><h3><%= post.title %> </h3> <%= post.body %></p>
              
                <div class="btn-group">
                    <div> 
                        <%= link_to "View", post_path(post), :class =>'btn btn-md btn-outline-secondary' %>
                    </div>
                <div class="btn-group">
                    <div> 
                        <%= link_to "Edit", edit_post_path(post), :class =>'btn btn-md btn-outline-secondary' %>
                    </div>
                </div>
                </div>
                 </div>
             </div>
<% end %>

row 必须先通过 each post

<div class="row">
  <% @posts.each do |post| %>
    <div class="col-md-4">
      <div class="card">
        <div class="card-title">
          <%= post.title %>
        </div>
      </div>
    </div>
  <% end %>
</div>