活动管理员中的表单让我可以选择插入空值
The form in the active admin gives me the option of inserting an empty value
我在用户模型中有这个枚举
enum role: { Principal: 0, Teacher: 1 }
在活动管理员中,在创建用户表单中,插入角色的输入让我可以选择插入空字符串。
我怎样才能让它只给我选项 Principal
和 Teacher
?
ActiveAdmin.register User do
actions :all, except: [:edit]
permit_params :email, :name, :password, :password_confirmation, :role
form do |f|
f.inputs do
f.input :email
f.input :name
f.input :password
f.input :password_confirmation
f.input :role
end
f.actions
end
end
为此你可以传递一个include_blank: false
选项
根据您的代码表示:-
....
....
f.input :role, include_blank: false
....
....
我在用户模型中有这个枚举
enum role: { Principal: 0, Teacher: 1 }
在活动管理员中,在创建用户表单中,插入角色的输入让我可以选择插入空字符串。
我怎样才能让它只给我选项 Principal
和 Teacher
?
ActiveAdmin.register User do
actions :all, except: [:edit]
permit_params :email, :name, :password, :password_confirmation, :role
form do |f|
f.inputs do
f.input :email
f.input :name
f.input :password
f.input :password_confirmation
f.input :role
end
f.actions
end
end
为此你可以传递一个include_blank: false
选项
根据您的代码表示:-
....
....
f.input :role, include_blank: false
....
....