This @grades is overwritten for every single iteration here so you're not doing what you think you are.

Also:
```ruby
Grade.where(student_section_enrollment_id: student)
```