[RUBY] The problem that the contents of params are completely displayed in the [Rails] view

This is Qiita's first post.

Currently, I am creating an EC site with Ruby on Rails. When displaying the product list, the phenomenon that the contents (?) Of params are displayed in a row at the bottom of the view occurred as shown below.

It looks like this at the bottom of the view

#<Item id: 5, title: "Ah ah", artist: "Ah ah", text: "Ah ah", genre_id: 15, country: "JP", format_id: 2, status_id: 2, price: 500, stock: 1, created_at: "2020-09-30 15:55:20", updated_at: "2020-09-30 15:55:20">,# <Item id: 4, title: "Good", artist: "Good", text: "Good", genre_id: 13, country: "JP", format_id: 2, status_id: 2, price: 5000, stock: 1, created_at: "2020-09-30 15:32:51", updated_at: "2020-09-30 15:32:51">,

The following is omitted
#app/views/items/index.html.erb

<%= render "shared/header" %>
<div class="main-wrapper">
  <div class="item-wrapper">
    <%= @items.each do |item| %>
      <div class="item">
        <div class="item-image-content">
          <%= image_tag item.image, class:"item-image" %>
        </div>
        <div class="item-format">
          <%= item.format.name %>
        </div>
        <div class="item-artist">
          <%= item.artist %>
        </div>
        <div class="item-title">
          <%= item.title %>
        </div>
        <div class="item-price">
          <%= item.price %>Circle(tax included)
        </div>
      </div>
    <% end %>
  </div>
</div>

At first I thought I forgot to close the tag, but it seems that it is different.

It was actually a very simple mistake.

<%= @items.each do |item| %>

I equated it with <% =%> even though I didn't actually see it in the view.

<% @items.each do |item| %>

If you remove =, the contents of params that were displayed in a row disappeared. It was a new learning that if you add = to something that is not displayed in the view, this will happen.

Recommended Posts

The problem that the contents of params are completely displayed in the [Rails] view
The identity of params [: id] in rails
Solved the problem that all the data in the table was displayed
Line breaks in the entered text are not displayed in view
[Rails] Check the contents of the object
The problem that XML attributes are sorted arbitrarily in Android Studio
Problem that the attribute of User model becomes nil in ActionMailer
Check the contents of params with pry
[Rails] About the error that the image is not displayed in the production environment
[Ruby On Rails] How to search the contents of params using include?
[Order method] Set the order of data in Rails
JAVA: jar, aar, view the contents of the file
[Java] What to do if the contents saved in the DB and the name of the enum are different in the enum that reflects the DB definition
[Ruby on Rails] Implementation of validation that works only when the conditions are met
Rails The concept of view componentization of Rails that I want to convey to those who want to quit
Introducing the settings and reference articles that are first done in Rails new development
Install multiple submit buttons in Rails View to get the value of the pressed button
[Java] The problem that uploaded images are not updated due to the influence of cache
About the problem of deadlock in parallel processing in gem'sprockets' 4.0
[Rails] How to get the contents of strong parameters
SSL in the local environment of Docker / Rails / puma
[Rails] How to display an image in the view
[Rails] What are params?
[Rails] Why using find_by in scope and returning all records instead of nil if there are no records that match the conditions
Determine that the value is a multiple of 〇 in Ruby
Identify threads in the Java process that are wasting CPU
[Rails] The problem that pry-byebug does not stop through breakpoints
(Ruby on Rails6) Display of the database that got the id of the database
Delete all the contents of the list page [Ruby on Rails]
Rails sorting function implementation (displayed in order of number of like)
[Rails] Solving the problem that session timeout does not work
A program that counts the number of words in a List
[Rails] Where to be careful in the description of validation
[Rails] How to display information stored in the database in view
How to solve the problem that the website image is not displayed after deploying to heroku on Rails 5
Let's implement the condition that the circumference and the inside of the Ougi shape are included in Java [Part 2]
Let's implement the condition that the circumference and the inside of the Ougi shape are included in Java [Part 1]
Explanation of the FizzBuzz problem
View monthly calendar in Rails
Solved the problem that the scroll event did not fire in JQuery
[Spring Boot] Mock the contents that are autowired outside the scope [JUnit 5]
[Rails] Read the RSS of the site and return the contents to the front
Replace preview by uploading by clicking the image in file_field of Rails
Form that receives the value of the repeating item in Spring MVC
How to write the view when Vue is introduced in Rails?
[Rails + Webpacker] I want to use images of assets! Until you can view the image in Vue.js