title: Ruby on Rails model not recognized for preload?
body: <p>I am trying to join two tables in a mariadb database. The halls table and the residence_staff tables. The goal is to display all the names of the managers for each hall and what hall they work in. When I run the application I get this error: Hall(hallId: integer, hallName: text, street: text, city: text, postcode: integer, phoneNumber: integer, sfaffNumber: integer) was not recognized for preload</p>
  
  <p>I have no idea what this means.</p>
  
  <p><strong>Halls model</strong></p>
  
  <pre><code>class Hall &lt; ApplicationRecord
    has_many :ResidenceStaffs
  end
  </code></pre>
  
  <p><strong>residence_staff Model</strong></p>
  
  <pre><code>class ResidenceStaff &lt; ApplicationRecord
    belongs_to :Hall
  
        class &lt;&lt; self
  
          def managers
            where(position: 'manager')
          end
        end
  end
  </code></pre>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>class HomeController &lt; ApplicationController
  
    def index
      @residence_staff = ResidenceStaff.all
      @residence_staff_managers = ResidenceStaff.managers.includes(Hall)
    end
  end
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;h1&gt;Title&lt;/h1&gt;
  
  &lt;div&gt;
    &lt;% @residence_staff_managers.each do |residence_staff| %&gt;
      &lt;%= residence_staff.fName%&gt;
      &lt;%= residence_staff.hallName%&gt;
    &lt;% end %&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have a feeling it is an issue with database mygrations but I am not entirely sure. Also,</p>
  
  <p><strong>Schema.rb</strong></p>
  
  <pre><code>ActiveRecord::Schema.define(version: 20180426051412) do
  
    create_table "advisor", primary_key: "advisorNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "fName", null: false
      t.text "lName", null: false
      t.text "position", null: false
      t.text "deptName", null: false
      t.integer "phoneNumber", null: false
      t.string "email", limit: 100, null: false
      t.integer "roomNumber", null: false
      t.index ["advisorNumber"], name: "Advisor_advisorNumber_uindex", unique: true
      t.index ["email"], name: "Advisor_email_uindex", unique: true
    end
  
    create_table "hall_of_residences", primary_key: "hallName", id: :string, limit: 50, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.string "street", limit: 50, null: false
      t.text "city", null: false
      t.integer "postcode", null: false
      t.integer "phoneNumber", null: false
      t.text "hall", null: false
      t.integer "staffNumber", null: false
      t.index ["hallName"], name: "HallOfResidence_hallName_uindex", unique: true
      t.index ["staffNumber"], name: "HallOfResidence_ResidenceStaff_staffNumber_fk"
    end
  
    create_table "halls", primary_key: "hallId", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "hallName", limit: 255, null: false
      t.text "street", null: false
      t.text "city", null: false
      t.integer "postcode", null: false
      t.integer "phoneNumber", null: false
      t.integer "sfaffNumber", null: false
      t.index ["sfaffNumber"], name: "halls_residence_staffs_staffNumber_fk"
    end
  
    create_table "invoice", primary_key: "invoiceNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.string "semester", limit: 50
      t.date "paymentDue"
      t.text "studentFName", null: false
      t.text "studentLName", null: false
      t.string "roomLocation", limit: 50, null: false
      t.text "city", null: false
      t.string "street", limit: 50, null: false
      t.integer "postcode", null: false
      t.integer "leaseNumber", null: false
      t.index ["invoiceNumber"], name: "Invoice_invoiceNumber_uindex", unique: true
      t.index ["leaseNumber"], name: "Invoice_Lease_leaseNumber_fk"
    end
  
    create_table "invoice_payment", primary_key: "paymentID", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.date "datePayed", null: false
      t.string "method", limit: 50, null: false
      t.date "dateOfFirstReminder"
      t.date "dateOfSecondReminder"
      t.integer "muNum", null: false
      t.index ["muNum"], name: "InvoicePayment_Student_mUNumber_fk"
      t.index ["paymentID"], name: "InvoicePayment_paymentID_uindex", unique: true
    end
  
    create_table "lease", id: false, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.integer "leaseNumber", null: false
      t.string "duration", limit: 50, null: false
      t.text "studentFName", null: false
      t.text "studentLName", null: false
      t.integer "placeNumber", null: false
      t.integer "roomNumber", null: false
      t.text "city", null: false
      t.string "street", limit: 50, null: false
      t.integer "postcode", null: false
      t.date "dateToLeave", null: false
      t.date "dateToEnter", null: false
      t.integer "mUNum", null: false
      t.index ["leaseNumber"], name: "Lease_leaseNumber_uindex", unique: true
      t.index ["mUNum"], name: "Lease_Student_mUNumber_fk"
      t.index ["placeNumber"], name: "Lease_placeNumber_uindex", unique: true
    end
  
    create_table "next_of_kin", primary_key: "nextID", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "fName", null: false
      t.text "lName", null: false
      t.text "relationship", null: false
      t.text "city", null: false
      t.string "street", limit: 100, null: false
      t.integer "postcode", null: false
      t.integer "phoneNumber", null: false
      t.integer "mUNum", null: false
      t.index ["mUNum"], name: "NextOfKin_Student_mUNumber_fk"
      t.index ["nextID"], name: "NextOfKin_nextID_uindex", unique: true
    end
  
    create_table "parking_lot", primary_key: "lotNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "lotName", null: false
      t.string "street", limit: 100, null: false
      t.text "city", null: false
      t.integer "postcode", null: false
      t.integer "maxSpace", null: false
      t.integer "availability", null: false
      t.index ["lotNumber"], name: "ParkingLot_lotNumber_uindex", unique: true
    end
  
    create_table "residence_staffs", primary_key: "staffNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "fName", null: false
      t.text "lName", null: false
      t.string "email", limit: 100, null: false
      t.text "homeCity", null: false
      t.string "street", limit: 50, null: false
      t.integer "postal", null: false
      t.date "dob", null: false
      t.text "gender"
      t.text "position", null: false
      t.string "location", limit: 50, null: false
      t.integer "phoneNumber", null: false
      t.integer "inspectedRoomID", null: false
      t.string "hall", limit: 50, null: false
      t.index ["inspectedRoomID"], name: "ResidenceStaff_StudentApartmentInspection_inspectedRoomID_fk"
      t.index ["staffNumber"], name: "ResidenceStaff_staffNumber_uindex", unique: true
    end
  
    create_table "room", primary_key: "placeNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.string "rentRate", limit: 50, null: false
      t.text "availability", null: false
      t.integer "roomNumber"
      t.string "hallName", limit: 50
      t.integer "apartmentNumber"
      t.index ["apartmentNumber"], name: "room_StudentFlats_apartmentNumber_fk"
      t.index ["hallName"], name: "room_HallOfResidence_hallName_fk"
    end
  
    create_table "staff", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.datetime "created_at", null: false
      t.datetime "updated_at", null: false
      t.text "fName"
    end
  
    create_table "student", primary_key: "mUNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "fName", null: false
      t.text "lName", null: false
      t.string "street", limit: 100, null: false
      t.text "city", null: false
      t.integer "postcode", null: false
      t.integer "phoneNumber", null: false
      t.string "email", limit: 100, null: false
      t.date "dob", null: false
      t.text "gender"
      t.text "standing", null: false
      t.text "nationality", null: false
      t.string "specialNeeds", limit: 100
      t.text "major", null: false
      t.string "statusOfStudent", limit: 100
      t.text "minor"
      t.text "comments"
      t.integer "advisorNumber", null: false
      t.index ["advisorNumber"], name: "Student_Advisor_advisorNumber_fk"
      t.index ["email"], name: "Student_email_uindex", unique: true
      t.index ["mUNumber"], name: "Student_mUNumber_uindex", unique: true
    end
  
    create_table "student_apartment_inspection", primary_key: "inspectedRoomID", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.text "inspectorName", null: false
      t.date "dateOfInspection", null: false
      t.text "apartmentCondition", null: false
      t.text "comments"
      t.index ["inspectedRoomID"], name: "StudentApartmentInspection_inspectedRoomID_uindex", unique: true
    end
  
    create_table "student_flats", primary_key: "apartmentNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.integer "numberOfRooms", null: false
      t.text "city", null: false
      t.string "street", limit: 50, null: false
      t.integer "postcode", null: false
      t.integer "leaseID", null: false
      t.index ["apartmentNumber"], name: "StudentFlats_apartmentNumber_uindex", unique: true
      t.index ["leaseID"], name: "StudentFlats_Lease_leaseNumber_fk"
    end
  
    create_table "vehicle", primary_key: "vNumber", id: :integer, default: nil, force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t|
      t.string "plateNumber", limit: 10, null: false
      t.text "color", null: false
      t.text "manufacturer", null: false
      t.string "brand", limit: 50, null: false
      t.integer "mUNum", null: false
      t.integer "lotNumber", null: false
      t.index ["lotNumber"], name: "Vehicle_ParkingLot_lotNumber_fk"
      t.index ["mUNum"], name: "Vehicle_Student_mUNumber_fk"
      t.index ["plateNumber"], name: "Vehicle_plateNumber_uindex", unique: true
      t.index ["vNumber"], name: "Vehicle_vNumber_uindex", unique: true
    end
  
    add_foreign_key "hall_of_residences", "residence_staffs", column: "staffNumber", primary_key: "staffNumber", name: "HallOfResidence_ResidenceStaff_staffNumber_fk"
    add_foreign_key "halls", "residence_staffs", column: "sfaffNumber", primary_key: "staffNumber", name: "halls_residence_staffs_staffNumber_fk"
    add_foreign_key "invoice", "lease", column: "leaseNumber", primary_key: "leaseNumber", name: "Invoice_Lease_leaseNumber_fk"
    add_foreign_key "invoice_payment", "student", column: "muNum", primary_key: "mUNumber", name: "InvoicePayment_Student_mUNumber_fk"
    add_foreign_key "lease", "student", column: "mUNum", primary_key: "mUNumber", name: "Lease_Student_mUNumber_fk"
    add_foreign_key "next_of_kin", "student", column: "mUNum", primary_key: "mUNumber", name: "NextOfKin_Student_mUNumber_fk"
    add_foreign_key "residence_staffs", "student_apartment_inspection", column: "inspectedRoomID", primary_key: "inspectedRoomID", name: "ResidenceStaff_StudentApartmentInspection_inspectedRoomID_fk"
    add_foreign_key "room", "hall_of_residences", column: "hallName", primary_key: "hallName", name: "room_HallOfResidence_hallName_fk"
    add_foreign_key "room", "student_flats", column: "apartmentNumber", primary_key: "apartmentNumber", name: "room_StudentFlats_apartmentNumber_fk"
    add_foreign_key "student", "advisor", column: "advisorNumber", primary_key: "advisorNumber", name: "Student_Advisor_advisorNumber_fk"
    add_foreign_key "student_flats", "lease", column: "leaseID", primary_key: "leaseNumber", name: "StudentFlats_Lease_leaseNumber_fk"
    add_foreign_key "vehicle", "parking_lot", column: "lotNumber", primary_key: "lotNumber", name: "Vehicle_ParkingLot_lotNumber_fk"
    add_foreign_key "vehicle", "student", column: "mUNum", primary_key: "mUNumber", name: "Vehicle_Student_mUNumber_fk"
  end
  </code></pre>