Home>
I want to jump to the new page from index

An error occurs when accessing the new post page from the top page.

NoMethodError in HomesController # new
undefined method `[]'for nil: NilClass
Corresponding source code
class HomesController</pre>
<pre><code data-language = "homesindexHTML"><% = render "shared/header"%><% = render "shared/footer"%>
<header class ='top-page-header'>  <% = link_to image_tag ("meiwa.png", class: "meiwa-icon"), "/"%>    <ul class ='lists-right'>  <% if user_signed_in?%>    <Li>Hello,<% = link_to "# {current_user.lastname} 's", root_path, class: "user-firstname"%></li>    <li><% = link_to'logout', destroy_user_session_path, method:: delete, class: "logout"%></li>    <li><% = link_to image_tag ("new.png", class: "new-home"), new_home_path%></li>  <% else%>    <li><% = link_to'login', new_user_session_path, class: "login"%></li>    <li><% = link_to'new registration', new_user_registration_path, class: "sign-up"%></li>  <% end%></ul></header>
class Home</pre>
<pre><code data-language = "prefecturerb">class Prefecture</pre>
<pre><code data-language = "classrb">class Class</pre>
<pre><code data-language = "routesrb">Rails.application.routes.draw do
  devise_for: users
  root to:'homes # index'
  resources: homes
end
What I tried

Confirmation of each model and association
Confirmation of table name description error

I don't understand how the new action works.
Thank you.

Supplementary information (FW/tool version, etc.)
<header><% = link_to image_tag ('meiwa.png', size: '185x50'), "/"%></header>     Enter property information   <% = form_with (model: @home, local: true) do | f |%>  Let's pass a<% # instance so that a message is displayed when an error occurs. %><% = render'shared/error_messages', model: f.object%><% # // Let's pass an instance so that a message will be displayed when an error occurs. %><% #Exhibited image%>                Property image
      <span>Required</span>                <p>        Click to upload file
      </p>    <% = f.file_field: images, name:'home [images] []', id: "home-image"%>                      <% #/Property image%><% # Property name and age, nearest walking time%>                Property Name
      <span>Required</span>        <% = f.text_area: home_name, class: "homes-text", id: "home-name", placeholder: "Product name (up to 40 characters required)", maxlength: "40"%>                      Age Nearest station (walking to minutes)
        <span>Required</span>            <% = f.text_area: age, class: "homes-text", id: "item-info", placeholder: "age-year nearest station (walk-minute)", rows: "7", maxlength: " 1000 "%>      <% #/Property name and age, nearest walking time%><% # Contact%>                          Person in charge
        <span>Required</span>                        Full name
              <% = f.text_area: name, class: "input-default", id: "name", placeholder: "Example) furima Taro"%>                            phone number
        <span>Required</span>            <% = f.text_field: tel, class: "input-default", id: "phone-number", placeholder: "Example) 09012345678", maxlength: "11"%>                            mail address
        <span>Required</span>            <% = f.email_field: email, class: "input-default", id: "email", placeholder: "either PC or mobile", autofocus: true%>          <% #/Contact%><% # Location%>                Property address
      <span>Required</span>                            Property area<% #prefecture%>      <span>Required</span>            <% = f.collection_select (: prefecture_id, Prefecture.all,: id,: name, {},

 {class: "select-box", id: "home-prefecture"})%>                            Property area<% # Tokyo 23 wards%>      <span>Required</span>            <% = f.collection_select (: class_id, Class.all,: id,: name, {},

 {class: "select-box", id: "home-class"})%>                            Municipalities
        <span>optional</span>            <% = f.text_field: city, class: "input-default", id: "city", placeholder: "Example) Midori-ku, Yokohama"%>                            address
        <span>Required</span>            <% = f.text_field: address, class: "input-default", id: "addresses", placeholder: "Example) 1-1-1 Aoyama"%>      <% #/Location%><% # Selling price%>                Selling price
                              price
        <span>Required</span>            <% = f.text_field: price, class: "price-input", id: "item-price", placeholder: "Enter in half-width numbers"%>                            Interest rate at sale (%)
        <span>Required</span>            <span>      <% = f.text_field: rate, class: "rate-input", id: "item-price", placeholder: "Enter in half-width numbers"%>    </span>                            rent
        <span>Required</span>              <span></span>Yen
        <% = f.text_field: rent, class: "rent-input", id: "item-price", placeholder: "Enter in half-width numbers"%>                                    Management fee
          <span>Required</span>                <span></span>Yen
        <% = f.text_field: management, class: "price-input", id: "item-price", placeholder: "Enter in half-width numbers"%>                  <% #/Selling price%><% # Residents%>                         Resident
              <span>Required</span>              <%% w (with occupancy and without occupancy) .each.with_index do | ingredient, i |%>      <label>        <% = check_box_tag'home [ingredients] []', ingredient, false, id: "home_ingredients_ # {i}"%>        <% = ingredient%>      </label>      <% end%>                  <% #/Residents%><% # Bottom button%>      <% = f.submit "submit", class: "sell-btn"%>  <% = link_to'return', root_path, class: "back-btn"%>  #/Bottom button%><% end%><%
  • Answer # 1

    Things to worry about

    Represents the property areaClassIs covered with Ruby's Class, so it is likely to cause some trouble.
    WardOrDistrictI think that is appropriate, but please check by looking up the dictionary yourself

    has_one_attached: imageBut for validates and viewsimagesA column name like multiple images will appear.