Home>

"Name Error in Books # show" is displayed in the error content, but I do not understand the cause.
The code is pasted below, so could you please tell me the cause?
Thank you.

NameError in Books # show
Showing /home/ec2-user/environment/bookers2-debug/app/views/users/_profile.html.erb where line # 2 raised:
undefined local variable or method `user'for #<#<Class: 0x00007f171dae2870>: 0x00007f171dc3bd70>
Did you mean? super
Extracted source (around line # 2):
1
2
3
Four
Five
6
<table>
  ↓ Error applicable part
  <tr><% = attachment_image_tag user,: profile_image,: fill, 100, 100, fallback: "no_image.jpg"%></tr>
  <tr>
      <th>name</th>
      <th><% = user.name%></th>
class UsersController</pre>
<pre><code data-language = "showhtmlerb">
    
         User info 
      <% = render'profile', user: @user%>
         New book 
      <% = render'books/form', book: @book%>
    
    
         Books 
      <table>
          <thead>
              <tr>
                  <th></th>
                  <th>Title</th>
                  <th>Opinion</th>
                  <th colspan = "3"></th>
              </tr>
          </header>
          <tbody>
              <% @ books.each do | book |%>
                  <tr>
                      <td>
                          <% = link_to user_path (book.user) do%>
                              <% = attachment_image_tag (book.user,: profile_image,: fill, 50, 50, fallback: "no-image-mini.jpg")%>
                          <% end%>
                      </td>
                      <td><% = link_to book.title, book_path (book), class: "book_ # {book.id}"%></td>
                      <td><% = book.body%></td>
                  </tr>
              <% end%>
          </tbody>
      </table>
    

↓ Below is a partial template


    
         User info 
      <% = render'profile', user: @user%>
         New book 
      <% = render'books/form', book: @book%>
    
    
         Books 
      <!-Books list->
      <table>
          <thead>
              <tr>
                  <th></th>
                  <th>Title</th>
                  <th>Opinion</th>
                  <th colspan = "3"></th>
              </tr>
          </header>
          <tbody>
              <% @ books.each do | book |%>
                  <tr>
                      <td>
                          <% = link_to user_path (book.user) do%>
                              <% = attachment_image_tag (book.user,: profile_image,: fill, 50, 50, fallback: "no-image-mini.jpg")%>
                          <% end%>
                      </td>
                      <td><% = link_to book.title, book_path (book), class: "book_ # {book.id}"%></td>
                      <td><% = book.body%></td>
                  </tr>
              <% end%>
          </tbody>
      </table>
      <!-Books list->