我有一个表单,我在其中传递了一个名为的字段 :type,我想检查它的值是否在允许的类型数组内,以便不允许任何人发布不允许的类型。
数组看起来像
@allowed_types = [
'type1',
'type2',
'type3',
'type4',
'type5',
'type6',
'type7',
etc...
]
我试过使用 validates_exclusion_oforvalidates_inclusion_of但它似乎不起作用