I am getting the error message NoMethodError in Clients#index, and Rails won't show me the client orders for some reason. I can't locate the issue.
This is the message I get when I click at the link:
Showing /home/kim91/Dev/Dolls-1/app/views/clients/index.html.slim where line #34 raised:
undefined method `orders' for #<Client id: 1, navn: "Bo Petersen", nummer: "", cvr_nr: 25621603, telefon: "", email: "", fax: "", kontakt: "", client_type_id: nil, beskrivelse: "Ophørt - Oprydning i foråret 2022\n", created_at: "2022-03-22 02:22:50.590978000 +0000", updated_at: "2022-03-22 02:22:50.590978000 +0000", subcontractor_cvr_nr: nil, type: nil, subcontractor_id: nil>''
This is the code:
h1 Listing Clients
table.table.table-striped.table-hover.datatable
thead.thead-dark
tr
th Navn
/th Nummer
th Cvr nr
/th Telefon
th Email
/th Fax
/th Kontakt
/th Client type
/th Beskrivelse
th Loc Cnt
th Order Cnt
th
th
th
tbody
- @clients.each do |client|
tr
td = client.navn
/td = client.nummer
td = client.cvr_nr
/td = client.telefon
td = client.email
/td = client.fax
/td = client.kontakt
/td = client.client_type&.name
/td = client.beskrivelse
td = client.collection_locations.size
td = client.orders.size
td = link_to 'Show', client
td = link_to 'Edit', edit_client_path(client)
td = link_to 'Destroy', client, data: { confirm: 'Are you sure?' }, method: :delete
br
= link_to 'New Client', new_client_path
Is there anyone that can help locate the issue here??