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->
-
Answer # 1
Related articles
- ruby on rails - about multi-word search to multiple columns using ransack
- ruby on rails - about rails create action
- ruby on rails - about saving comments
- ruby on rails - about the description in applicationjs
- ruby on rails - about deploying apps using s3 function
- ruby - about routing using rails collection
- ruby - [rails] about the error that occurs when deleting likes (routing error)
- ruby on rails - rails render: about the matter that the url after new is different
- ruby on rails - [rails] about the problem that screen transition is not possible (error does not occur)
- ruby on rails - about image distribution on heroku and s3
- ruby on rails - about conditional branching using elsif
- ruby on rails - about rails composite indexes
- ruby on rails - about primary key/natural key/surrogate key in db design
- ruby - about rails routing
- ruby on rails - about nomethoderror in skilscontroller # create
- ruby - about embedding rails videos
- ruby on rails - about the matter that does not transition to the detail page
- ruby on rails - nameerror in looks # index
- ruby on rails 6 - rails tutorial chapter 14 about follow, unfollow, following? methods
Related questions
- ruby - passing variables using render partial
- ruby - deployment error on heroku
- ruby - output the total integer value held by each user
- ruby - i want to use the search method for active hash data
- ruby - destroy action does not respond
- ruby - how do you see the rails controller relative path? (carrierwave directory deleted)
- ruby - when deploying on capistrano, i get the error "access denied for user'ec2-user' @'localhost' (using password: no)&qu
- javascript - run multiple times with js + each do
- how to reflect the layout downloaded from the external site in ruby on rails?
- ruby - how nice! function routes do not pass well (relation) [rails]
What is worrisome
Books #show
That's right.What is being presented
UsersController
andusers/show.html.erb
I thinkBooksController
andbooks/show.html.erb
I think you should also see.