LoginSignup
0
0

More than 3 years have passed since last update.

rails indexページでeach文書いたら、変な表示になった

Posted at

railsでindex表示に失敗した話

以下のようなブラウザ表示になった

スクリーンショット 2021-04-17 16.52.38.png


本当は、こうしたい

スクリーンショット 2021-04-17 16.57.41.png

解決法

index.html.erb
<table>
    <thead>
      <tr>
        <td>Title</td>
        <td>Opinion</td>
      </tr>
    </thead>
    <tbody>
      <% @books.each do |b| %>
        <tr>
          <td><%= link_to b.title, book_path(b) %></td>
          <td><%= b.body %></td>
        </tr>
      <% end %>
    </tbody>
  </table>

<% @books.each do |b| %>でなく<%= @books.each do |b| %>のように=をつけていたため変な表示になっていた


間違いあれば教えてください。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0