Undefined Method Error Caused by Line in Submit Script

I am trying to setup OnDemand on our new Grace-Hopper cluster. Since these nodes have only one GPU (it’s a CPU/GPU superchip), I have setup a checkbox on our form to select whether or not to use the GPU. I am receiving the following error message when I go to submit the job:
undefined method `gpu' for nil:NilClass

The line the error is mentioning is this line in the submit.yml.erb file:

- <%= context.gpu == "1" ? '--gres=gpu:1' : '' %>

I’m not sure how to implement the logic to either print --gres=gpu:1 or print nothing in the submit.yml.erb file. Any assistance on this would be greatly appreciated.

The relevant form section is below:

gpu:
widget: “check_box”
label: “Enable GPU”
checked_value: 1
unchecked_value: 0
help: “Check this box to enable the GPU.”

The full submit script is below:

---
batch_connect:
  template: "basic"
  conn_params:
    - jupyter_api
script:
  queue_name: <%= bc_queue %>
  wall_time: <%= bc_num_hours.to_i * 3600 %>
  email_on_started: <%= bc_email_on_started %>
  job_name: "OOD_JUP"
  native:
    - "-N<%= bc_num_slots.blank? ? 1 : bc_num_slots.to_i %>"
    - "--ntasks-per-node=<%= slurm_cores.to_i %>"
    - "--mem=<%= slurm_mem.to_i %>G"
    - <%= context.gpu == "1" ? '--gres=gpu:1' : '' %>
    - "--reservation=<%= slurm_reservation %>"

Thanks!