Ruby on Rails Table creation error, recreating ID does not display correctly on the web page.

Ruby on rails ID display is not correct

< H2 > I tried to recreate the table on the terminal, but the ID showed 4, and I was advised to use each_with_index, but I didn"t know where to put it. < / H2 >

related codes

< div class= "container" >
< div class= "row" >

<div class="col-xs-3">
  <ul class="list-group">
    <li class="list-group-item">
      
      <ul class="list-group">
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
      </ul>
    </li>
    <li class="list-group-item">
      
      <ul class="list-group">
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
        <li class="list-group-item"></li>
      </ul>
    </li>
  </ul>
</div>
<div class="col-xs-9">
  <div class="row">
    <div class="col-xs-12">
      <div class="jumbotron">
        <h1><%= @ad[:title] %></h1>
        

<%= @ad[:des] %>

<a class="btn btn-primary btn-lg" href="-sharp" role="button"><%= @ad[:action_title] %></a>

</div> </div> </div> <div class="row"> <% @products.each do |product| %> <div class="col-xs-3"> <div class="thumbnail"> <%= image_tag product[:image_url] %> <div class="caption"> <h3><%= "-sharp{product[:id]}. -sharp{product[:name]}" %></h3>

<%= product[:description] %>

<a href="-sharp" class="btn btn-primary" role="button">Button</a> <a href="-sharp" class="btn btn-default" role="button">Button</a>

</div> </div> </div> <% end %> </div> <div class="row"> <div class= "col-xs-12"> <nav aria-label="Page navigation"> <ul class="pagination"> <% if @page > @first_page %> <li> <%= link_to root_path(page:(@page-1)) do%> <span aria-hidden="true"></span> <% end %> </li> <% end %> <% (@first_page..@last_page).each do |page_number|%> <li><%= link_to page_number,root_path(page:page_number)%> </li> <% end %> <% if @page < @last_page %> <li> <%= link_to root_path(page:(@page+1)) do%> <span aria-hidden="true"></span> <% end %> </li> <% end %> </ul> </nav> </div> </div> </div>

< / div >
< / div >

what result do you expect? The error message you actually see is!

what I want is

clipboard.png

clipboard.png

tablecommand id 234 5.
2018-07-25 2.12.34
clipboard.png

Mar.30,2021

you should have the following assignment statement in your controller method, right?

@products = Product.all

can be changed to

@products = Product.order(:id)

just have product sort by "id".

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-7ac684-2cc87.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-7ac684-2cc87.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?