Home>

I want you to resolve NameError.
I would like to see the naming standard, but it didn't solve it.
Thank you.

Error message

Applicable source code

orders_controller.rb

class OrdersController</pre>
<p>index.html.erb</p>
<pre><code><% @ menu.each do | t |%>
    <p><% = t.name%></p>
<% end%>

schema.rb

ActiveRecord :: Schema.define (version: 2019_11_30_132114) do
  create_table "menus", force:: cascade do | t |
    t.integer "orderid"
    t.string "name"
    t.integer "number"
    t.boolean "receive"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end
end

Search for similar questions such as StackOverflow and execute solutions

Supplemental information (FW/tool version etc.)

Ruby on rails
VScode

  • Answer # 1

    It is an error that

    ClassMenusdoes not exist (cannot be found).

    I think you have a model file

    app/models/menu.rb.

    Table information in DB is plural, so it ismenusin Schema file, but Class is used in singular form, so if you do it asMenu.allIt may work.