在联系表(邮寄者)中添加 class 到 check_box_tag

Adding a class to check_box_tag in contact form (mailer)

我有一个带有复选框的联系表单,要求同意向用户发送电子邮件 - 因为在每个字段中都有一个反馈给网站所有者的密钥。我正在尝试将 class 添加到复选框本身 input-consent,但是当我尝试以下操作时:

<%= check_box_tag(:consent, class: "input-consent") %>

我收到此错误:

app/views/registrations/new.html.erb:56: syntax error, unexpected ',', expecting ')'.

我应该怎么写这个?

你能试试这个吗?

<%= check_box_tag :consent, 1, false, class: 'input-consent' %>

Refer to check_box_tag here