验证 HABTM 复选框
我有多个来自多对多关系的复选框,并且我正在尝试验证它们,以便所有字段都不需要值才能继续。目前,如果我尝试创建一个用户,而不通过复选框将其分配给组/角色,我也会得到
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
同样的信息,当分配了组但所有其他字段都留空时,我仍然会收到上述错误。
当一切都有价值时,它就会完美地运作。
下面的表格
I have multiple check boxes from a many to many relationship, And i'm trying to validate them so that none of the fields need a value to continue. At the moment if i try to create a user without assigning them to a group/role through the checkboxes i get
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.each
Also when a group is assigned but all other fields are left empty i still get the above error.
When everything has a value it works perfectly.
Form below
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果未选中所有复选框,请使用空数组
如果仍然存在问题,则需要在此处复制粘贴控制器代码
use the empty array if all checkboxes unchecked
if you still have the issue, you need to copy-paste your controller code here