Always getting not null object even though there are no objects with these parameters;

@dknutsen of course I will. So, this function unesiOcenu(val1, val2) works perfectly when I insert grade for the first time in that class for the first student (it doesn’t need to be first on the list) and some subject. But every next time when I try to insert grade in that class for other student from another subject or for that previous student from another subject it always insert grade from the subject I started with. Which is very strange because:

  1. Model class is not in relationship with model grade in any way, only with models student and subject; (Is there a way to check if some record exists before I create a new one?)

  2. I checked with alert order and I always get different values for student and grade when I try to insert grade for another student and subject in that class, which means parameters val1, val2 are changeable so there are no bugs there.

It’s like it doesn’t filter every time or I am not using find method correctly. Please check if there are errors with template, maybe I am wrong there.

<br> <br> <br> <br> <br>


<h2> Chosen class: {{}} </h2>


<i> Current students in class: </i> <br>

{{#each model.students as |student|}}
  <li> {{student.firstName}}  {{student.lastName}} </li>
    {{#if showS}}
    <br> Current subjects in class: 
    {{#each model.subjects as |subject|}}
      <br> <b> {{subject.title}} </b>
       Choose grade: 
      <select onchange={{action (mut ocena) value="target.value"}}>
        <option value="1"> 1 </option>
        <option value="2"> 2 </option>
        <option value="3"> 3 </option>
        <option value="4"> 4 </option>
        <option value="5"> 5 </option>
      <button {{action 'unesiOcenu'}}> Insert mark for student </button>

      {{#each student.grades as |grades|}}
				<th> {{grades.subject.title}} </th>
				<th> {{grades.marks}} </th>
  <b> Currently there are no students for the class! </b>

  <button class="choose" {{action 'showSubjects'}}> Show subjects </button> 

-Also I will leave screenshots of bug I am seeing, I think that then it will be clear what the bug is.

-First insertion of the grade:

-Second insertion of the grade (from different subject):