[Ruby] NameError in Incomes#index error

less than 1 minute read

After creating a household account book application

NameError in Incomes#index

Got an error

index.html.erb


<% @page_title = "List of income subjects" %>
<h2><%= page_title %></h2>

<% if @incomes.present? %>
<table>
    <thead>
        <tr>
            <th>Subject name</th>
            <th>Remarks</th>
        </tr>
    </thead>
    <tbody>
        <% @incomes.each do |income| %>
            <tr>
                <td><%=income.name %></td>
                <td><%=income.description %></td>
            </tr>
        <% end %>
    </tbody>
</table>

<% else %>
    <p>There are no registered subjects</p>
<% end %>

If you look closely,…

Before page on the second line

@

Isn’t it missing?

index.html.erb



<h2><%= @page_title %></h2>

This is the error resolution. I’m having trouble with typos and a few omissions, so programming is a problem.

Especially for me as a beginner.

I will continue to do my best while fighting errors

Tags:

Updated: