LoginSignup
0
0

More than 3 years have passed since last update.

NameError in Incomes#index のエラー

Posted at

家計簿アプリ作成の上で

NameError in Incomes#index 

のエラーが出ました

index.html.erb
<% @page_title = "収入科目一覧" %>
<h2><%= page_title %></h2>

<% if @incomes.present? %>
<table>
    <thead>
        <tr>
            <th>科目名</th>
            <th>備考</th>
        </tr>
    </thead>
    <tbody>
        <% @incomes.each do |income| %>
            <tr>
                <td><%= income.name %></td>
                <td><%= income.description %></td>
            </tr>
        <% end %>
    </tbody>
</table>

<% else %>
    <p>登録されている科目がありません</p>
<% end %>

よく見てみると、、、

2行目のpageの前

@

が抜けているではないか。

index.html.erb

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

これで無事エラー解消です。
タイプミスとか、少しの抜けとかでエラーになっちゃうから困りますよね、プログラミングというものは。

初心者の私は特に。

エラーと闘いながら、今後も引き続き頑張ります

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0