rub ###
I am making a photo posting application with Ruby on rails.

Among them, the partial template _prototype.html.erb
I want to display, but an error is displayed.

The following error has occurred when displaying the posted content list.

! [Image description] (f31933a42db3dccb06cd13e0b9d26f00.jpeg)
[Link content] (https://gyazo.com/e00ff514ae3353cfdac044ba483bee8b)

NoMethodError in Prototypes # index
Showing /Users/shin/projects/protospace-32080/app/views/prototypes/_prototype.html.erb where line # 2 raised:

undefined local variable or method `prototype'for #<#: 0x00007fbd106d7548> Did you mean? @prototypes

Corresponding source code _prototype.html.erb

<% = image_tag prototype.image, class:'card__img' if prototype.image.attached?%>
  <% = link_to "prototype.title", root_path, class:: card__title%>
    <% = "prototype.catch_copy"%>
  <% = link_to "by prototype.user.name", root_path, class :: card__user%>
<% if user_signed_in?%>
  <% # Display the following when logged in%>
       <% = link_to current_user.name, root_path, class:: greeting__link%>
  <% # // Display the above when logged in%>
  <% end%>
    <% # Display prototype post list with partial template after implementing post function%>
    <% = render partial: "prototype", collecition: @prototypes%>
class PrototypesController
What I tried

I thought that the image tag method could not be applied well, so I changed the description in various ways, but the error still persists.

  • Answer # 1

    -<% = render partial: "prototype", collecition: @prototypes%>
    +<% = render partial: "prototype", collection: @prototypes%>

Related articles